mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: track history being stored
This is done because sometimes we receive history after the first connect too, and to ensure the "isLatest" flag is accurate -- we ensure no history was received previously
This commit is contained in:
@@ -22,10 +22,10 @@ export const downloadHistory = async(msg: proto.IHistorySyncNotification) => {
|
||||
}
|
||||
|
||||
export const processHistoryMessage = (item: proto.IHistorySync, historyCache: Set<string>) => {
|
||||
const isLatest = historyCache.size === 0
|
||||
const messages: proto.IWebMessageInfo[] = []
|
||||
const contacts: Contact[] = []
|
||||
const chats: Chat[] = []
|
||||
|
||||
switch (item.syncType) {
|
||||
case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_BOOTSTRAP:
|
||||
case proto.HistorySync.HistorySyncHistorySyncType.RECENT:
|
||||
@@ -71,11 +71,13 @@ export const processHistoryMessage = (item: proto.IHistorySync, historyCache: Se
|
||||
break
|
||||
}
|
||||
|
||||
const didProcess = !!(chats.length || messages.length || contacts.length)
|
||||
|
||||
return {
|
||||
chats,
|
||||
contacts,
|
||||
messages,
|
||||
isLatest,
|
||||
didProcess,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user