fix: Fixed In Memory Store: contacts.upsert handle (#144)

This commit is contained in:
dudagervasio
2023-06-15 21:45:24 -03:00
committed by GitHub
parent 2f438a6539
commit aa9872b039

View File

@@ -146,11 +146,13 @@ export default (
logger.debug({ chatsAdded }, 'synced chats') logger.debug({ chatsAdded }, 'synced chats')
const oldContacts = contactsUpsert(newContacts) const oldContacts = contactsUpsert(newContacts)
for(const jid of oldContacts) { if(isLatest) {
delete contacts[jid] for(const jid of oldContacts) {
delete contacts[jid]
}
} }
logger.debug({ deletedContacts: oldContacts.size, newContacts }, 'synced contacts') logger.debug({ deletedContacts: isLatest ? oldContacts.size : 0, newContacts }, 'synced contacts')
for(const msg of newMessages) { for(const msg of newMessages) {
const jid = msg.key.remoteJid! const jid = msg.key.remoteJid!
@@ -161,6 +163,10 @@ export default (
logger.debug({ messages: newMessages.length }, 'synced messages') logger.debug({ messages: newMessages.length }, 'synced messages')
}) })
ev.on('contacts.upsert', contacts => {
contactsUpsert(contacts)
})
ev.on('contacts.update', updates => { ev.on('contacts.update', updates => {
for(const update of updates) { for(const update of updates) {
if(contacts[update.id!]) { if(contacts[update.id!]) {