fix load image

This commit is contained in:
Peter Maquiran
2022-01-20 15:33:55 +01:00
parent e86d9d8b35
commit 38fcf7e514
3 changed files with 38 additions and 18 deletions
@@ -813,7 +813,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
card.el.style['z-index'] = 11;
}
downloadFileMsg(msg) {
downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
@@ -826,6 +826,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
msg.file = {
guid: msg.file.guid,
image_url: this.downloadFile,
type: msg.file.type
}
await this.storage.set(msg.file.guid, this.downloadFile).then(() => {
console.log('IMAGE SAVED')
@@ -839,7 +845,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async openPreview(msg) {
if (msg.file.image_url === null) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
this.downloadFileMsg(msg)
} else {