diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index b6c4dca14..3a98cd9a3 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -638,18 +638,15 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { //"title": this.capturedImageTitle , //"text": "description", "title_link_download": false, - //"image_url": this.capturedImage, + "type": "application/img", + "guid": '', + "image_url": imageData }] }) let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise() - updateMessage({ - file: { - type: "application/img", - guid: guid.path, - image_url: imageData - } - }) + message.file.guid = guid.path + this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => { @@ -659,6 +656,23 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } else if (event.type === HttpEventType.Response) { var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '')); console.log('add picture to chat',fileImage); + + updateMessage({ + file: { + type: "application/img", + guid: guid.path, + image_url: fileImage + }, + attachments: [{ + //"title": this.capturedImageTitle , + //"text": "description", + "title_link_download": false, + "type": "application/img", + guid: guid.path, + "image_url": fileImage + }] + }) + await this.storage.set(guid.path, fileImage).then(() => { console.log('add picture to chat IMAGE SAVED') message.getFileFromDb() diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 3c4da98de..d4cf829be 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -658,10 +658,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { "image_url": imageData }, attachments: [{ - //"title": this.capturedImageTitle , - //"text": "description", + "title": file.name, "title_link_download": false, - //"image_url": this.capturedImage, + "image_url": imageData, }] }) @@ -744,10 +743,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { "image_url": fileImage }, attachments: [{ - //"title": this.capturedImageTitle , - //"text": "description", + "title": capturedImageTitle , + "text": "description", "title_link_download": false, - //"image_url": this.capturedImage, + "image_url": capturedImage, }] }) diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index a9ad0190f..cb4ec06fb 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -457,10 +457,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy "image_url": capturedImage }, attachments: [{ - //"title": this.capturedImageTitle , - //"text": "description", + "title": capturedImageTitle , + "text": "description", "title_link_download": false, - //"image_url": this.capturedImage, }] }) @@ -582,10 +581,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy "image_url": imageData }, attachments: [{ - //"title": this.capturedImageTitle , - //"text": "description", + "title": file.name , + "text": "description", "title_link_download": false, - //"image_url": this.capturedImage, }] })