MOBILE-2632 message: Apply infinite-load error fix to new views

main
Dani Palou 2018-11-23 14:41:24 +01:00
parent ea78f65656
commit 36dd9035dd
4 changed files with 11 additions and 6 deletions

View File

@ -37,6 +37,6 @@
</h2>
</a>
<core-infinite-loading [enabled]="canLoadMore" (action)="loadMoreMembers($event)"></core-infinite-loading>
<core-infinite-loading [enabled]="canLoadMore" (action)="loadMoreMembers($event)" [error]="loadMoreError"></core-infinite-loading>
</core-loading>
</ion-content>

View File

@ -31,6 +31,7 @@ export class AddonMessagesConversationInfoPage implements OnInit {
conversation: any;
members = [];
canLoadMore = false;
loadMoreError = false;
protected conversationId: number;
@ -72,6 +73,8 @@ export class AddonMessagesConversationInfoPage implements OnInit {
* @return {Promise<any>} Promise resolved when done.
*/
protected fetchMembers(loadingMore?: boolean): Promise<any> {
this.loadMoreError = false;
const limitFrom = loadingMore ? this.members.length : 0;
return this.messagesProvider.getConversationMembers(this.conversationId, limitFrom).then((data) => {
@ -94,7 +97,7 @@ export class AddonMessagesConversationInfoPage implements OnInit {
loadMoreMembers(infiniteComplete?: any): Promise<any> {
return this.fetchMembers(true).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'Error getting members.');
this.canLoadMore = false;
this.loadMoreError = true;
}).finally(() => {
infiniteComplete && infiniteComplete();
});

View File

@ -59,7 +59,7 @@
<div *ngIf="favourites.conversations && favourites.expanded">
<ng-container *ngTemplateOutlet="conversationsTemplate; context: {conversations: favourites.conversations}"></ng-container>
<!-- The infinite loading cannot be inside the ng-template, it fails because it doesn't find ion-content. -->
<core-infinite-loading [enabled]="favourites.canLoadMore" (action)="loadMoreConversations(favourites, $event)"></core-infinite-loading>
<core-infinite-loading [enabled]="favourites.canLoadMore" (action)="loadMoreConversations(favourites, $event)" [error]="favourites.loadMoreError"></core-infinite-loading>
<ion-item text-wrap *ngIf="favourites.conversations.length == 0">
<p>{{ 'addon.messages.nofavourites' | translate }}</p>
</ion-item>
@ -75,7 +75,7 @@
<div *ngIf="group.conversations && group.expanded">
<ng-container *ngTemplateOutlet="conversationsTemplate; context: {conversations: group.conversations, avatarOptional: true}"></ng-container>
<!-- The infinite loading cannot be inside the ng-template, it fails because it doesn't find ion-content. -->
<core-infinite-loading [enabled]="group.canLoadMore" (action)="loadMoreConversations(group, $event)"></core-infinite-loading>
<core-infinite-loading [enabled]="group.canLoadMore" (action)="loadMoreConversations(group, $event)" [error]="group.loadMoreError"></core-infinite-loading>
<ion-item text-wrap *ngIf="group.conversations.length == 0">
<p>{{ 'addon.messages.nogroupmessages' | translate }}</p>
</ion-item>
@ -90,7 +90,7 @@
<div *ngIf="individual.conversations && individual.expanded">
<ng-container *ngTemplateOutlet="conversationsTemplate; context: {conversations: individual.conversations}"></ng-container>
<!-- The infinite loading cannot be inside the ng-template, it fails because it doesn't find ion-content. -->
<core-infinite-loading [enabled]="individual.canLoadMore" (action)="loadMoreConversations(individual, $event)"></core-infinite-loading>
<core-infinite-loading [enabled]="individual.canLoadMore" (action)="loadMoreConversations(individual, $event)" [error]="individual.loadMoreError"></core-infinite-loading>
<ion-item text-wrap *ngIf="individual.conversations.length == 0">
<p>{{ 'addon.messages.nomessages' | translate }}</p>
</ion-item>

View File

@ -253,6 +253,8 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
* @return {Promise<any>} Promise resolved when done.
*/
fetchDataForOption(option: any, loadingMore?: boolean): Promise<void> {
option.loadMoreError = false;
const limitFrom = loadingMore ? option.conversations.length : 0;
return this.messagesProvider.getConversations(option.type, option.favourites, limitFrom).then((data) => {
@ -353,7 +355,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
loadMoreConversations(option: any, infiniteComplete?: any): Promise<any> {
return this.fetchDataForOption(option, true).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true);
option.canLoadMore = false;
option.loadMoreError = true;
}).finally(() => {
infiniteComplete && infiniteComplete();
});