mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Don't dup presence updates
This commit is contained in:
@@ -393,11 +393,16 @@ export class WAConnection extends Base {
|
|||||||
chat.presences = chat.presences || {}
|
chat.presences = chat.presences || {}
|
||||||
|
|
||||||
const presence = { ...(chat.presences[jid] || {}) } as WAPresenceData
|
const presence = { ...(chat.presences[jid] || {}) } as WAPresenceData
|
||||||
|
|
||||||
if (update.t) presence.lastSeen = +update.t
|
if (update.t) presence.lastSeen = +update.t
|
||||||
else if (update.type === Presence.unavailable && (presence.lastKnownPresence === Presence.available || presence.lastKnownPresence === Presence.composing)) {
|
else if (update.type === Presence.unavailable && (presence.lastKnownPresence === Presence.available || presence.lastKnownPresence === Presence.composing)) {
|
||||||
presence.lastSeen = unixTimestampSeconds()
|
presence.lastSeen = unixTimestampSeconds()
|
||||||
}
|
}
|
||||||
presence.lastKnownPresence = update.type
|
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]
|
const contact = this.contacts[jid]
|
||||||
if (contact) {
|
if (contact) {
|
||||||
|
|||||||
Reference in New Issue
Block a user