mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix message
This commit is contained in:
@@ -72,10 +72,16 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
|
||||
<img
|
||||
*ngIf="message.oneShot != true && attachment.blobURl != true"
|
||||
[src]="attachment.safeFile"
|
||||
(load)="onImageLoad(message, messageIndex)"
|
||||
(error)="onImageError()"
|
||||
>
|
||||
|
||||
<img
|
||||
*ngIf="message.oneShot != true"
|
||||
[src]="attachment.safeFile"
|
||||
*ngIf="message.oneShot != true && attachment.blobURl"
|
||||
[src]="attachment.safeFile|safehtml"
|
||||
(load)="onImageLoad(message, messageIndex)"
|
||||
(error)="onImageError()"
|
||||
>
|
||||
|
||||
@@ -320,10 +320,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
// }
|
||||
// return true; // Keep messages without an id
|
||||
// });
|
||||
|
||||
|
||||
messages = messages.sort((a: any, b: any) => a.$createAt - b.$createAt)
|
||||
|
||||
console.time("mappingTime");
|
||||
for(const message of messages) {
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
@@ -334,12 +331,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
allMessage.push(new MessageViewModal(message))
|
||||
}
|
||||
console.timeEnd("mappingTime");
|
||||
|
||||
console.time("mappingTime");
|
||||
|
||||
this.messages1[this.roomId] = allMessage
|
||||
|
||||
console.timeEnd("mappingTime");
|
||||
|
||||
|
||||
// if(messages.length >= 1) {
|
||||
// this.messages1[this.roomId].push(LastMessage)
|
||||
@@ -370,13 +367,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
for(const message of this.messages1[this.roomId]) {
|
||||
if(message.hasAttachment && message.attachments[0].source != MessageAttachmentSource.Webtrix) {
|
||||
|
||||
if(message.$id) {
|
||||
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
|
||||
if(result.isOk()) {
|
||||
message.attachments[0].safeFile = result.value
|
||||
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
|
||||
if(result.isOk()) {
|
||||
message.attachments[0].safeFile = result.value
|
||||
|
||||
if(result.value.startsWith('blob:http')) {
|
||||
message.attachments[0].blobURl = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -437,26 +436,34 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
listenToIncomingMessage() {
|
||||
this.messageReceiveSubject?.unsubscribe();
|
||||
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.roomId).subscribe(async (message) => {
|
||||
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.roomId).subscribe(async (_message) => {
|
||||
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
const date = whatsappDate(_message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
this.date[date] = true
|
||||
const Ballon = XBallon(message)
|
||||
const Ballon = XBallon(_message)
|
||||
this.messages1[this.roomId].push(Ballon)
|
||||
}
|
||||
|
||||
const message = new MessageViewModal(_message)
|
||||
this.messages1[this.roomId].push(new MessageViewModal(message))
|
||||
|
||||
console.log('message=======', message)
|
||||
|
||||
if(message.hasAttachment) {
|
||||
|
||||
const result = await this.chatServiceService.downloadMessageAttachmentByMessageId({
|
||||
$messageId: message.$id,
|
||||
$messageId: message.id,
|
||||
id: message.attachments[0].id
|
||||
})
|
||||
|
||||
if(result.isOk()){
|
||||
if(result.isOk()) {
|
||||
message.attachments[0].safeFile = result.value
|
||||
if((result.value as unknown as string).startsWith('blob:http')) {
|
||||
message.attachments[0].blobURl = true
|
||||
} else {
|
||||
message.attachments[0].blobURl = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user