Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Lazy load notifications dropdown

Chocobozzz6c6740adedce
diff --git a/client/src/app/header/notification-dropdown.component.html b/client/src/app/header/notification-dropdown.component.html
index 789a36b177..fb3a79f9ea 100644
--- a/client/src/app/header/notification-dropdown.component.html
+++ b/client/src/app/header/notification-dropdown.component.html
@@ -24,7 +24,7 @@
} @else {
<div
ngbDropdown autoClose="outside" placement="bottom" container="body" dropdownClass="dropdown-notifications"
- #dropdown="ngbDropdown" (shown)="onDropdownShown()" (hidden)="onDropdownHidden()"
+ #dropdown="ngbDropdown" (openChange)="$event === true ? onDropdownShown() : onDropdownHidden()"
>
<button
i18n-title title="View your notifications" class="peertube-button tertiary-button rounded-icon-button disable-dropdown-caret notification-inbox-dropdown"
@@ -60,17 +60,19 @@
</div>
</div>
- <div *ngIf="!loaded" class="loader mt-4">
- </div>
+ @defer (when opened) {
+ <div *ngIf="!loaded" class="loader mt-4">
+ <my-loader size="xl" [loading]="loaded"></my-loader>
+ </div>
- @defer (when loaded) {
<my-user-notifications
[ignoreLoadingBar]="true" [infiniteScroll]="false" [itemsPerPage]="10"
[markAllAsReadSubject]="markAllAsReadSubject" (notificationsLoaded)="onNotificationLoaded()"
></my-user-notifications>
} @placeholder {
- <my-loader size="xl" [loading]="loaded"></my-loader>
-
+ <div class="loader mt-4">
+ <my-loader size="xl" loading="true"></my-loader>
+ </div>
}
<div class="all-notifications">
diff --git a/client/src/app/header/notification-dropdown.component.ts b/client/src/app/header/notification-dropdown.component.ts
index f22fe100b8..41e0792b80 100644
--- a/client/src/app/header/notification-dropdown.component.ts
+++ b/client/src/app/header/notification-dropdown.component.ts
@@ -83,7 +83,6 @@ export class NotificationDropdownComponent implements OnInit, OnDestroy {
}
onDropdownHidden () {
- this.loaded = false
this.opened = false
}
diff --git a/client/src/app/shared/shared-main/common/loader.component.ts b/client/src/app/shared/shared-main/common/loader.component.ts
index e6c08a183c..e7a30d5fef 100644
--- a/client/src/app/shared/shared-main/common/loader.component.ts
+++ b/client/src/app/shared/shared-main/common/loader.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input } from '@angular/core'
+import { booleanAttribute, Component, Input } from '@angular/core'
import { NgIf, NgStyle } from '@angular/common'
@Component({
@@ -8,7 +8,7 @@ import { NgIf, NgStyle } from '@angular/common'
imports: [ NgIf, NgStyle ]
})
export class LoaderComponent {
- @Input() loading: boolean
+ @Input({ transform: booleanAttribute }) loading: boolean
@Input() size: 'sm' | 'xl'
private readonly sizes = {
diff --git a/client/src/app/shared/shared-main/menu/horizontal-menu.component.ts b/client/src/app/shared/shared-main/menu/horizontal-menu.component.ts
index fb4a7cc448..379b2c21ce 100644
--- a/client/src/app/shared/shared-main/menu/horizontal-menu.component.ts
+++ b/client/src/app/shared/shared-main/menu/horizontal-menu.component.ts
@@ -90,7 +90,7 @@ export class HorizontalMenuComponent implements OnInit, OnChanges, OnDestroy {
})
if (!entry) {
- if (this.menuEntries.length !== 0) {
+ if (this.menuEntries.length !== 0 && currentUrl !== '/') {
logger.info(`Unable to find entry for ${currentUrl} or ${currentComponentPath}`, { menuEntries: this.menuEntries })
}
diff --git a/client/src/app/shared/standalone-notifications/user-notifications.component.ts b/client/src/app/shared/standalone-notifications/user-notifications.component.ts
index 4cf3fcffce..a3f25fcc0f 100644
--- a/client/src/app/shared/standalone-notifications/user-notifications.component.ts
+++ b/client/src/app/shared/standalone-notifications/user-notifications.component.ts
@@ -38,8 +38,6 @@ export class UserNotificationsComponent implements OnInit {
) { }
ngOnInit () {
- console.log('loaded')
-
this.componentPagination = {
currentPage: 1,
itemsPerPage: this.itemsPerPage, // Reset items per page, because of the @Input() variable