Skip to content

Commit

Permalink
Revert "Process read syncs after batches of messages"
Browse files Browse the repository at this point in the history
This reverts commit eccace4.
  • Loading branch information
indutny-signal committed Aug 2, 2021
1 parent 6637fc2 commit c5de4c6
Showing 1 changed file with 22 additions and 43 deletions.
65 changes: 22 additions & 43 deletions ts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,6 @@ export async function startApp(): Promise<void> {
window.Signal.Services.lightSessionResetQueue = lightSessionResetQueue;
lightSessionResetQueue.pause();

const readSyncQueue = new window.PQueue({
concurrency: 1,
timeout: 1000 * 60 * 2,
});
readSyncQueue.pause();

window.Whisper.deliveryReceiptQueue = new window.PQueue({
concurrency: 1,
timeout: 1000 * 60 * 2,
Expand Down Expand Up @@ -2484,8 +2478,6 @@ export async function startApp(): Promise<void> {
window.waitForEmptyEventQueue = waitForEmptyEventQueue;

async function onEmpty() {
window.Signal.Util.setBatchingStrategy(false);

await Promise.all([
window.waitForAllBatchers(),
window.flushAllWaitBatchers(),
Expand All @@ -2504,7 +2496,6 @@ export async function startApp(): Promise<void> {

profileKeyResponseQueue.start();
lightSessionResetQueue.start();
readSyncQueue.start();
window.Whisper.deliveryReceiptQueue.start();
window.Whisper.Notifications.enable();

Expand All @@ -2522,6 +2513,8 @@ export async function startApp(): Promise<void> {
);
}

window.Signal.Util.setBatchingStrategy(false);

const attachmentDownloadQueue = window.attachmentDownloadQueue || [];

// NOTE: ts/models/messages.ts expects this global to become undefined
Expand Down Expand Up @@ -3785,43 +3778,29 @@ export async function startApp(): Promise<void> {
uuid: senderUuid,
});

if (readSyncQueue.isPaused) {
window.log.info(
'delaying processing of read sync',
sender,
senderUuid,
envelopeTimestamp,
senderId,
'for message',
timestamp
);
}

readSyncQueue.add(() => {
window.log.info(
'read sync',
sender,
senderUuid,
envelopeTimestamp,
senderId,
'for message',
timestamp
);
window.log.info(
'read sync',
sender,
senderUuid,
envelopeTimestamp,
senderId,
'for message',
timestamp
);

const receipt = ReadSyncs.getSingleton().add({
senderId,
sender,
senderUuid,
timestamp,
readAt,
});
const receipt = ReadSyncs.getSingleton().add({
senderId,
sender,
senderUuid,
timestamp,
readAt,
});

receipt.on('remove', ev.confirm);
receipt.on('remove', ev.confirm);

// Note: Here we wait, because we want read states to be in the database
// before we move on.
return ReadSyncs.getSingleton().onSync(receipt);
});
// Note: Here we wait, because we want read states to be in the database
// before we move on.
return ReadSyncs.getSingleton().onSync(receipt);
}

async function onVerified(ev: VerifiedEvent) {
Expand Down

0 comments on commit c5de4c6

Please sign in to comment.