Maintain epoch on message-update

This commit is contained in:
Adhiraj
2020-10-08 20:07:51 +05:30
parent 4b1be0d9e3
commit c87f06752d

View File

@@ -44,9 +44,17 @@ export class WAConnection extends Base {
const chat = this.chats.get(jid) const chat = this.chats.get(jid)
if (!chat) return if (!chat) return
// reinsert to update // reinsert to update
if (chat.messages.delete (message)) chat.messages.insert (message) const oldMessage = chat.messages.get (WA_MESSAGE_ID(message))
if (oldMessage) {
this.emit ('message-update', message) message['epoch'] = oldMessage['epoch']
chat.messages.delete (oldMessage)
chat.messages.insert (message)
this.emit ('message-update', message)
} else {
chat.messages.insert (message)
this.emit ('message-new', message)
}
}) })
// If a user's contact has changed // If a user's contact has changed
this.registerCallback (['action', null, 'user'], json => { this.registerCallback (['action', null, 'user'], json => {