fix: history sync missing contacts

This commit is contained in:
Adhiraj Singh
2022-03-07 18:17:43 +05:30
parent 9ca46635d6
commit 93262b38f4

View File

@@ -31,16 +31,13 @@ export const processHistoryMessage = (item: proto.IHistorySync, historyCache: Se
for(const chat of item.conversations) { for(const chat of item.conversations) {
const contactId = `c:${chat.id}` const contactId = `c:${chat.id}`
if(chat.name && !historyCache.has(contactId)) { if(chat.name && !historyCache.has(contactId)) {
contacts.push({ contacts.push({ id: chat.id, name: chat.name })
id: chat.id,
name: chat.name
})
historyCache.add(contactId) historyCache.add(contactId)
} }
for(const { message } of chat.messages || []) { for(const { message } of chat.messages || []) {
const uqId = `${message?.key.remoteJid}:${message.key.id}` const uqId = `${message.key.remoteJid}:${message.key.id}`
if(message && !historyCache.has(uqId)) { if(!historyCache.has(uqId)) {
messages.push(message) messages.push(message)
historyCache.add(uqId) historyCache.add(uqId)
} }
@@ -57,7 +54,7 @@ export const processHistoryMessage = (item: proto.IHistorySync, historyCache: Se
case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME: case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME:
for(const c of item.pushnames) { for(const c of item.pushnames) {
const contactId = `c:${c.id}` const contactId = `c:${c.id}`
if(historyCache.has(contactId)) { if(!historyCache.has(contactId)) {
contacts.push({ notify: c.pushname, id: c.id }) contacts.push({ notify: c.pushname, id: c.id })
historyCache.add(contactId) historyCache.add(contactId)
} }