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:
Adhiraj Singh
2022-06-07 21:18:51 +05:30
parent ea8b580db8
commit 5305730d82
7 changed files with 32 additions and 13 deletions

View File

@@ -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,
}
}