mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix message order on reconect
This commit is contained in:
@@ -369,19 +369,24 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.messageOnReconnectSubject?.unsubscribe()
|
||||
this.messageOnReconnectSubject = this.chatServiceService.listenToMessageLoadHistory({roomId: this.room.id}).subscribe((messages) => {
|
||||
|
||||
for(const message of messages.data) {
|
||||
for(const message of messages.data.reverse()) {
|
||||
const found = this.messages1[this.room.$id].find((e) => e.id == message.id)
|
||||
|
||||
if(!found) {
|
||||
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
this.date[date] = true
|
||||
const Ballon = XBallon(message)
|
||||
this.messages1[this.room.$id].push(Ballon)
|
||||
}
|
||||
|
||||
const msg = new MessageViewModal(message as any)
|
||||
Object.assign(msg, message)
|
||||
this.messages1[this.room.$id].push(msg)
|
||||
}
|
||||
}
|
||||
|
||||
this.messages1[this.room.$id].sort((a, b) => {
|
||||
return new Date(a.sentAt).getTime() - new Date(b.sentAt).getTime()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user