Add exhausted calculation

This commit is contained in:
SondreB 2023-02-10 15:59:26 +01:00
parent fd5f65ba4c
commit de2cb5e7fd
No known key found for this signature in database
GPG Key ID: D6CC44C75005FDBF
2 changed files with 10 additions and 3 deletions

View File

@ -25,8 +25,11 @@ export class UIService {
viewCounts = {
followingEventsViewCount: 5,
followingEventsViewExhausted: false,
rootEventsViewCount: 5,
rootEventsViewCountExhausted: false,
replyEventsViewCount: 5,
replyEventsViewCountExhausted: false,
};
#unreadNotificationsChanged: BehaviorSubject<number> = new BehaviorSubject<number>(0);
@ -249,18 +252,21 @@ export class UIService {
updateRootEventsView(start: number, count: number) {
this.viewCounts.rootEventsViewCount = count;
this.#lists.rootEventsView = this.#lists.rootEvents.slice(start, count);
this.viewCounts.rootEventsViewCountExhausted = count >= this.#lists.rootEvents.length;
this.#rootEventsView.next(this.#lists.rootEventsView);
}
updateReplyEventsView(start: number, count: number) {
this.viewCounts.replyEventsViewCount = count;
this.#lists.replyEventsView = this.#lists.replyEvents.slice(start, count);
this.viewCounts.replyEventsViewCountExhausted = count >= this.#lists.replyEvents.length;
this.#replyEventsView.next(this.#lists.replyEventsView);
}
updateFollowingEventsView(start: number, count: number) {
this.viewCounts.followingEventsViewCount = count;
this.#lists.followingEventsView = this.#lists.followingEvents.slice(start, count);
this.viewCounts.followingEventsViewExhausted = count >= this.#lists.followingEvents.length;
this.#followingEventsView.next(this.#lists.followingEventsView);
}

View File

@ -57,8 +57,8 @@
</div>
<div class="show-more centered">
<button *ngIf="!ui.exhausted" mat-button (click)="showMore()">Show more...</button>
<span *ngIf="ui.exhausted">Loading more events... or there are nothing more to show...</span>
<button *ngIf="!ui.viewCounts.rootEventsViewCountExhausted" mat-button (click)="showMore()">Show more...</button>
<span *ngIf="ui.viewCounts.rootEventsViewCountExhausted">Loading more events... or there are nothing more to show...</span>
</div>
</mat-tab>
<mat-tab label="Replies">
@ -82,7 +82,8 @@
</div>
<div class="show-more centered">
<button mat-button (click)="showMore()">Show more...</button>
<button *ngIf="!ui.viewCounts.replyEventsViewCountExhausted" mat-button (click)="showMore()">Show more...</button>
<span *ngIf="ui.viewCounts.replyEventsViewCountExhausted">Loading more events... or there are nothing more to show...</span>
</div>
</mat-tab>
<!-- <mat-tab label="Likes">