Don't dup presence updates

This commit is contained in:
Adhiraj Singh
2021-01-08 19:54:41 +05:30
parent 39802eb449
commit 500805236a

View File

@@ -393,11 +393,16 @@ export class WAConnection extends Base {
chat.presences = chat.presences || {}
const presence = { ...(chat.presences[jid] || {}) } as WAPresenceData
if (update.t) presence.lastSeen = +update.t
else if (update.type === Presence.unavailable && (presence.lastKnownPresence === Presence.available || presence.lastKnownPresence === Presence.composing)) {
presence.lastSeen = unixTimestampSeconds()
}
presence.lastKnownPresence = update.type
// no update
if(presence.lastKnownPresence === chat.presences[jid]?.lastKnownPresence && presence.lastSeen === chat.presences[jid]?.lastSeen) {
return
}
const contact = this.contacts[jid]
if (contact) {