Properly handle read syncs while offline

This commit is contained in:
Evan Hahn 2022-01-21 19:04:30 -06:00 committed by GitHub
parent 7fb23a1f6d
commit 884bfc0594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 16 deletions

View File

@ -70,27 +70,18 @@ export async function runReadOrViewSyncJob({
syncs: ReadonlyArray<SyncType>;
timestamp: number;
}>): Promise<void> {
let sendType: SendTypesType;
let doSync:
| typeof window.textsecure.messaging.syncReadMessages
| typeof window.textsecure.messaging.syncView;
if (isView) {
sendType = 'viewSync';
doSync = window.textsecure.messaging.syncView.bind(
window.textsecure.messaging
);
} else {
sendType = 'readSync';
doSync = window.textsecure.messaging.syncReadMessages.bind(
window.textsecure.messaging
);
}
if (!syncs.length) {
log.info("skipping this job because there's nothing to sync");
return;
}
let sendType: SendTypesType;
if (isView) {
sendType = 'viewSync';
} else {
sendType = 'readSync';
}
const syncTimestamps = syncs.map(sync => sync.timestamp);
log.info(
`sending ${sendType}(s) for timestamp(s) ${syncTimestamps.join(', ')}`
@ -115,6 +106,19 @@ export async function runReadOrViewSyncJob({
syncMessage: true,
});
let doSync:
| typeof window.textsecure.messaging.syncReadMessages
| typeof window.textsecure.messaging.syncView;
if (isView) {
doSync = window.textsecure.messaging.syncView.bind(
window.textsecure.messaging
);
} else {
doSync = window.textsecure.messaging.syncReadMessages.bind(
window.textsecure.messaging
);
}
try {
await Promise.all(
chunk(syncs, CHUNK_SIZE).map(batch => {