diff --git a/src/app/ui/chat/modal/messages/messages.page.ts b/src/app/ui/chat/modal/messages/messages.page.ts index c99670e57..7b14551fe 100644 --- a/src/app/ui/chat/modal/messages/messages.page.ts +++ b/src/app/ui/chat/modal/messages/messages.page.ts @@ -308,12 +308,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.messageDeleteSubject?.unsubscribe(); this.messageDeleteSubject = this.chatServiceService.listenToDeleteMessage(this.roomId).subscribe((deleteMessage) => { - console.log('delete class', deleteMessage); - const index = this.messages1[this.roomId].findIndex(e => e?.id === deleteMessage.id); // Use triple equals for comparison if (index !== -1) { // Check if the item was found - console.log('delete ==') this.messages1[this.roomId].splice(index, 1); // console.log('removed index', index); } else { @@ -330,7 +327,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { const index = this.messages1[this.roomId].findIndex(e => e?.id === updateMessage.id); // Use triple equals for comparison if (index !== -1) { // Check if the item was found - console.log('update ==') this.messages1[this.roomId][index].message = updateMessage.message this.messages1[this.roomId][index].reactions = updateMessage.reactions } else { @@ -344,19 +340,16 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.messageSendSubject?.unsubscribe(); this.messageSendSubject = this.chatServiceService.listenToSendMessage(this.roomId).subscribe((updateMessage) => { - console.log('update message', updateMessage); const index = this.messages1[this.roomId].findIndex(e => e?.requestId === updateMessage.requestId); // Use triple equals for comparison if (index !== -1) { // Check if the item was found - console.log('update ==') this.messages1[this.roomId][index].id = updateMessage.id let attachmentIndex = 0; for(const message of updateMessage.attachments) { - console.log('set attachmen id', message) this.messages1[this.roomId][index].attachments[attachmentIndex].id = message.id attachmentIndex++; } @@ -891,7 +884,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { 800, // maxHeight 0.9 // quality ).then((picture) => { - console.log('Selected: ', picture) imageBase64 = picture }); @@ -1081,39 +1073,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { }); } - - // getRoomMessageDB(roomId) { - // if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - // } else { - // this.sqlservice.getAllChatMSG(roomId).then((msg: any) => { - - // let chatmsgArray = []; - // msg.forEach(element => { - - - // let msgChat = { - // _id: element.Id, - // attachments: this.isJson(element.Attachments), - // channels: this.isJson(element.Channels), - // file: this.isJson(element.File), - // mentions: this.isJson(element.Mentions), - // msg: element.Msg, - // rid: element.Rid, - // ts: element.Ts, - // u: this.isJson(element.U), - // _updatedAt: element.UpdatedAt, - // image_url: this.isJson(element.image_url) - // } - - // chatmsgArray.push(msgChat) - // }); - - - - // }) - // } - // } - isJson(str) { try { JSON.parse(str); @@ -1125,46 +1084,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { - transformDataMSG(res) { - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - } else { - res.forEach(element => { - - 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: { - name: name, - path: `${IMAGE_DIR}/${name}`, - data: `data:image/jpeg;base64,${readFile.data}`, - }, */ - } - - // this.sqlservice.addChatMSG(chatmsg) - - }); - } - - } - - /* testeDownload(msg: MessageService) { - this.downloadFile = ""; - this.AttachmentsService.downloadFileAndStore(msg.file.guid); - } */ - - - downloadFileMsg(msg: any) { - msg.downloadFileMsg(); - } - b64toBlob(b64Data, contentType) { contentType = contentType || ''; var sliceSize = 512; @@ -1273,14 +1192,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { async openPreview(msg) { - if (msg.file.type === "application/webtrix") { this.viewDocument(msg.file, msg.attachments.image_url) } else { if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') { - this.downloadFileMsg(msg) - //this.testDownlod(msg) + // this.downloadFileMsg(msg) + // this.testDownlod(msg) } else { var str = msg.attachments[0].image_url; @@ -1334,14 +1252,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } - async audioPreview(msg) { - - if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') { - this.downloadFileMsg(msg) - } else { } - } - - imageSize(img) { var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); @@ -1361,25 +1271,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } - - // async ShareEmail(msg){ - // // Check if sharing via email is supported - // await Share.share({ - // title: msg.u.username, - // text: msg._updatedAt, - // url: msg.attachments[0].image_url, - // dialogTitle: 'Share with buddies', - // }); - // } - - async createDirectoryImage() { - await Filesystem.mkdir({ - path: IMAGE_DIR, - directory: Directory.Data, - recursive: true - }); - } - async compressImageBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise { return new Promise((resolve, reject) => { const image = new (window as any).Image(); @@ -1429,7 +1320,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { messageDelete(message: MessageEntity) { - // this.messageRepositoryService.sendMessageDelete() this.chatServiceService.messageDelete({ messageId: message.id, roomId: this.roomId,