fix message order

This commit is contained in:
Peter Maquiran
2022-07-15 10:06:55 +01:00
parent 48ef200f69
commit 345ca084f1
+27 -2
View File
@@ -39,6 +39,7 @@ export class RoomService {
name = ''
_updatedAt = {}
hasLoadHistory = false
hasLoadHistoryMessageRF = []
restoreFromOffline = false
duration = ''
isTyping = false
@@ -516,7 +517,7 @@ export class RoomService {
*/
async send({file = null, attachments = null, temporaryData = {}}) {
const localReference = uuidv4()
const localReference = uuidv4();
let offlineChatMessage = {
rid: this.id,
@@ -547,7 +548,9 @@ export class RoomService {
this.sortRoomList()
}
if(this.hasLoadHistory == false) {
this.hasLoadHistoryMessageRF.push(localReference)
}
}
@@ -703,6 +706,28 @@ export class RoomService {
}, 50)
this.hasLoadHistory = true
this.messageReorder();
}
async messageReorder() {
const reorderMessage: MessageService[] = this.messages.filter((message) =>
this.hasLoadHistoryMessageRF.includes(message?.localReference)
);
await this.messages.forEach( async (message, i) => {
if(this.hasLoadHistoryMessageRF.includes(message?.localReference)) {
this.messages.splice(i, 1)
}
})
this.hasLoadHistoryMessageRF = [];
reorderMessage.forEach((message) => {
this.messages.push(message)
});
}