Properly handle read syncs while offline
This commit is contained in:
parent
7fb23a1f6d
commit
884bfc0594
1 changed files with 20 additions and 16 deletions
|
@ -70,27 +70,18 @@ export async function runReadOrViewSyncJob({
|
||||||
syncs: ReadonlyArray<SyncType>;
|
syncs: ReadonlyArray<SyncType>;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}>): Promise<void> {
|
}>): 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) {
|
if (!syncs.length) {
|
||||||
log.info("skipping this job because there's nothing to sync");
|
log.info("skipping this job because there's nothing to sync");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sendType: SendTypesType;
|
||||||
|
if (isView) {
|
||||||
|
sendType = 'viewSync';
|
||||||
|
} else {
|
||||||
|
sendType = 'readSync';
|
||||||
|
}
|
||||||
|
|
||||||
const syncTimestamps = syncs.map(sync => sync.timestamp);
|
const syncTimestamps = syncs.map(sync => sync.timestamp);
|
||||||
log.info(
|
log.info(
|
||||||
`sending ${sendType}(s) for timestamp(s) ${syncTimestamps.join(', ')}`
|
`sending ${sendType}(s) for timestamp(s) ${syncTimestamps.join(', ')}`
|
||||||
|
@ -115,6 +106,19 @@ export async function runReadOrViewSyncJob({
|
||||||
syncMessage: true,
|
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 {
|
try {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
chunk(syncs, CHUNK_SIZE).map(batch => {
|
chunk(syncs, CHUNK_SIZE).map(batch => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue