Properly handle read syncs while offline

Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2022-01-21 18:10:02 -08:00 committed by GitHub
parent ce4f76be1f
commit 9c594c387f
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 => {