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;