Lazy load notifications dropdown
This commit is contained in:
parent
2ebfe772ed
commit
6c6740aded
|
@ -24,7 +24,7 @@
|
||||||
} @else {
|
} @else {
|
||||||
<div
|
<div
|
||||||
ngbDropdown autoClose="outside" placement="bottom" container="body" dropdownClass="dropdown-notifications"
|
ngbDropdown autoClose="outside" placement="bottom" container="body" dropdownClass="dropdown-notifications"
|
||||||
#dropdown="ngbDropdown" (shown)="onDropdownShown()" (hidden)="onDropdownHidden()"
|
#dropdown="ngbDropdown" (openChange)="$event === true ? onDropdownShown() : onDropdownHidden()"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
i18n-title title="View your notifications" class="peertube-button tertiary-button rounded-icon-button disable-dropdown-caret notification-inbox-dropdown"
|
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>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="!loaded" class="loader mt-4">
|
@defer (when opened) {
|
||||||
</div>
|
<div *ngIf="!loaded" class="loader mt-4">
|
||||||
|
<my-loader size="xl" [loading]="loaded"></my-loader>
|
||||||
|
</div>
|
||||||
|
|
||||||
@defer (when loaded) {
|
|
||||||
<my-user-notifications
|
<my-user-notifications
|
||||||
[ignoreLoadingBar]="true" [infiniteScroll]="false" [itemsPerPage]="10"
|
[ignoreLoadingBar]="true" [infiniteScroll]="false" [itemsPerPage]="10"
|
||||||
[markAllAsReadSubject]="markAllAsReadSubject" (notificationsLoaded)="onNotificationLoaded()"
|
[markAllAsReadSubject]="markAllAsReadSubject" (notificationsLoaded)="onNotificationLoaded()"
|
||||||
></my-user-notifications>
|
></my-user-notifications>
|
||||||
} @placeholder {
|
} @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">
|
<div class="all-notifications">
|
||||||
|
|
|
@ -83,7 +83,6 @@ export class NotificationDropdownComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropdownHidden () {
|
onDropdownHidden () {
|
||||||
this.loaded = false
|
|
||||||
this.opened = false
|
this.opened = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, Input } from '@angular/core'
|
import { booleanAttribute, Component, Input } from '@angular/core'
|
||||||
import { NgIf, NgStyle } from '@angular/common'
|
import { NgIf, NgStyle } from '@angular/common'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -8,7 +8,7 @@ import { NgIf, NgStyle } from '@angular/common'
|
||||||
imports: [ NgIf, NgStyle ]
|
imports: [ NgIf, NgStyle ]
|
||||||
})
|
})
|
||||||
export class LoaderComponent {
|
export class LoaderComponent {
|
||||||
@Input() loading: boolean
|
@Input({ transform: booleanAttribute }) loading: boolean
|
||||||
@Input() size: 'sm' | 'xl'
|
@Input() size: 'sm' | 'xl'
|
||||||
|
|
||||||
private readonly sizes = {
|
private readonly sizes = {
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class HorizontalMenuComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!entry) {
|
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 })
|
logger.info(`Unable to find entry for ${currentUrl} or ${currentComponentPath}`, { menuEntries: this.menuEntries })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,6 @@ export class UserNotificationsComponent implements OnInit {
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
console.log('loaded')
|
|
||||||
|
|
||||||
this.componentPagination = {
|
this.componentPagination = {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
itemsPerPage: this.itemsPerPage, // Reset items per page, because of the @Input() variable
|
itemsPerPage: this.itemsPerPage, // Reset items per page, because of the @Input() variable
|
||||||
|
|
Loading…
Reference in New Issue