MOBILE-3320 comments: Minor fixes on comments list

main
Pau Ferrer Ocaña 2021-05-25 13:15:57 +02:00
parent 02d2905c9a
commit e7d4588bcf
2 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -85,11 +85,11 @@ export class CoreCommentsProvider {
itemId: number,
area: string = '',
siteId?: string,
): Promise<CoreCommentsData | boolean> {
): Promise<CoreCommentsData | false> {
siteId = siteId || CoreSites.getCurrentSiteId();
// Convenience function to store a comment to be synchronized later.
const storeOffline = async (): Promise<boolean> => {
const storeOffline = async (): Promise<false> => {
await CoreCommentsOffline.saveComment(content, contextLevel, instanceId, component, itemId, area, siteId);
return false;