MOBILE-3833 forum: Fix check empty discussion list

main
Dani Palou 2022-04-12 13:00:42 +02:00
parent 7383dc1974
commit c6bdde182c
2 changed files with 14 additions and 2 deletions

View File

@ -40,11 +40,11 @@
</ion-card>
<ng-container *ngIf="forum">
<core-empty-box *ngIf="!discussions || discussions.empty" icon="far-comments"
<core-empty-box *ngIf="!discussions || !discussions.hasDiscussions" icon="far-comments"
[message]="'addon.mod_forum.forumnodiscussionsyet' | translate">
</core-empty-box>
<div *ngIf="discussions && !discussions.empty && sortingAvailable && selectedSortOrder" class="ion-text-wrap">
<div *ngIf="discussions?.hasDiscussions && sortingAvailable && selectedSortOrder" class="ion-text-wrap">
<core-combobox [modalOptions]="sortOrderSelectorModalOptions" listboxId="addon-mod-forum-sort-selector"
[label]="('core.sort' | translate)" (onChange)="setSortOrder($event)" [selection]="selectedSortOrder.label | translate"
interface="modal">

View File

@ -705,4 +705,16 @@ class AddonModForumDiscussionsManager extends CoreListItemsManager<AddonModForum
}
}
/**
* Check whether there is any discussion in the items.
*
* @return Whether there is a discussion.
*/
get hasDiscussions(): boolean {
const source = this.getSource();
const items = source.getItems();
return items !== null && items.some(item => !source.isNewDiscussionForm(item));
}
}