From e7d4588bcf2f79bca3dd8aebf66f1c0aad00ec5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 25 May 2021 13:15:57 +0200 Subject: [PATCH] MOBILE-3320 comments: Minor fixes on comments list --- src/core/features/comments/pages/viewer/viewer.page.ts | 7 ++++--- src/core/features/comments/services/comments.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/features/comments/pages/viewer/viewer.page.ts b/src/core/features/comments/pages/viewer/viewer.page.ts index 475b6ebad..1789a611e 100644 --- a/src/core/features/comments/pages/viewer/viewer.page.ts +++ b/src/core/features/comments/pages/viewer/viewer.page.ts @@ -153,7 +153,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { let comments = commentsResponse.comments.sort((a, b) => b.timecreated - a.timecreated); if (typeof commentsResponse.count != 'undefined') { - this.canLoadMore = (this.comments.length + comments.length) > commentsResponse.count; + this.canLoadMore = (this.comments.length + comments.length) < commentsResponse.count; } else { // Old style. this.canLoadMore = commentsResponse.comments.length > 0 && @@ -349,8 +349,9 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { const deletedOnline = await CoreComments.deleteComment(deleteComment); this.showDelete = false; - if (deletedOnline) { - const index = this.comments.findIndex((comment) => comment.id == comment.id); + if (deletedOnline && 'id' in comment) { + const index = this.comments.findIndex((commentinList) => commentinList.id == comment.id); + if (index >= 0) { this.comments.splice(index, 1); diff --git a/src/core/features/comments/services/comments.ts b/src/core/features/comments/services/comments.ts index e87d2e3b5..1c252e21c 100644 --- a/src/core/features/comments/services/comments.ts +++ b/src/core/features/comments/services/comments.ts @@ -85,11 +85,11 @@ export class CoreCommentsProvider { itemId: number, area: string = '', siteId?: string, - ): Promise { + ): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); // Convenience function to store a comment to be synchronized later. - const storeOffline = async (): Promise => { + const storeOffline = async (): Promise => { await CoreCommentsOffline.saveComment(content, contextLevel, instanceId, component, itemId, area, siteId); return false;