MOBILE-3320 comments: Minor fixes on comments list
parent
02d2905c9a
commit
e7d4588bcf
|
@ -153,7 +153,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
let comments = commentsResponse.comments.sort((a, b) => b.timecreated - a.timecreated);
|
let comments = commentsResponse.comments.sort((a, b) => b.timecreated - a.timecreated);
|
||||||
if (typeof commentsResponse.count != 'undefined') {
|
if (typeof commentsResponse.count != 'undefined') {
|
||||||
this.canLoadMore = (this.comments.length + comments.length) > commentsResponse.count;
|
this.canLoadMore = (this.comments.length + comments.length) < commentsResponse.count;
|
||||||
} else {
|
} else {
|
||||||
// Old style.
|
// Old style.
|
||||||
this.canLoadMore = commentsResponse.comments.length > 0 &&
|
this.canLoadMore = commentsResponse.comments.length > 0 &&
|
||||||
|
@ -349,8 +349,9 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
||||||
const deletedOnline = await CoreComments.deleteComment(deleteComment);
|
const deletedOnline = await CoreComments.deleteComment(deleteComment);
|
||||||
this.showDelete = false;
|
this.showDelete = false;
|
||||||
|
|
||||||
if (deletedOnline) {
|
if (deletedOnline && 'id' in comment) {
|
||||||
const index = this.comments.findIndex((comment) => comment.id == comment.id);
|
const index = this.comments.findIndex((commentinList) => commentinList.id == comment.id);
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
this.comments.splice(index, 1);
|
this.comments.splice(index, 1);
|
||||||
|
|
||||||
|
|
|
@ -85,11 +85,11 @@ export class CoreCommentsProvider {
|
||||||
itemId: number,
|
itemId: number,
|
||||||
area: string = '',
|
area: string = '',
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<CoreCommentsData | boolean> {
|
): Promise<CoreCommentsData | false> {
|
||||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
// Convenience function to store a comment to be synchronized later.
|
// 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);
|
await CoreCommentsOffline.saveComment(content, contextLevel, instanceId, component, itemId, area, siteId);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue