diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 7a0177c6b..faef30243 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -334,7 +334,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy console.log('GET FILE WEB', foo ) }); - this.storageservice.get('chatmsg').then((msg) => { + this.storageservice.get('chatmsg').then(async (msg) => { let msgArray =[]; msgArray = msg; msgArray.filter(data => data._id != this.roomId); @@ -344,25 +344,29 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy let newmgsArray = []; msgArray.forEach(async element => { console.log('GET FILE TRANSFORM',element.file.guid ) - if(element.file.guid == msg.file.guid) { - let chatmsg = { - _id: element._id, - attachments: element.attachments, - channels: element.channels, - file: element.file, - mentions: element.mentions, - msg: element.msg, - rid: element.rid, - ts: element.ts, - u: element.u, - _updatedAt: element._updatedAt, - image_url: this.downloadFile + try { + if(element.file.guid == msg.file.guid) { + let chatmsg = { + _id: element._id, + attachments: element.attachments, + channels: element.channels, + file: element.file, + mentions: element.mentions, + msg: element.msg, + rid: element.rid, + ts: element.ts, + u: element.u, + _updatedAt: element._updatedAt, + image_url: this.downloadFile + } + newmgsArray.push(chatmsg) } - newmgsArray.push(chatmsg) + } catch (error) { + } }); - - this.storageservice.store('chatmsg',newmgsArray); + await this.storageservice.remove('chatmsg'); + await this.storageservice.store('chatmsg',newmgsArray); }) }