Ensure queues are restarted once the empty event is received
This commit is contained in:
parent
2506d6ef9e
commit
d1f296a4af
1 changed files with 30 additions and 14 deletions
|
@ -1620,6 +1620,35 @@ export async function startApp(): Promise<void> {
|
||||||
window.addEventListener('online', onNavigatorOnline);
|
window.addEventListener('online', onNavigatorOnline);
|
||||||
window.addEventListener('offline', onNavigatorOffline);
|
window.addEventListener('offline', onNavigatorOffline);
|
||||||
|
|
||||||
|
window.Whisper.events.on('socketStatusChange', () => {
|
||||||
|
if (window.getSocketStatus() === SocketStatus.OPEN) {
|
||||||
|
pauseQueuesAndNotificationsOnSocketConnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 1. When the socket is connected, to avoid a flood of operations before we catch up,
|
||||||
|
// we pause some queues.
|
||||||
|
function pauseQueuesAndNotificationsOnSocketConnect() {
|
||||||
|
log.info('pauseQueuesAndNotificationsOnSocketConnect: pausing');
|
||||||
|
profileKeyResponseQueue.pause();
|
||||||
|
lightSessionResetQueue.pause();
|
||||||
|
onDecryptionErrorQueue.pause();
|
||||||
|
onRetryRequestQueue.pause();
|
||||||
|
window.Whisper.deliveryReceiptQueue.pause();
|
||||||
|
notificationService.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. After the socket finishes processing any queued messages, restart these queues
|
||||||
|
function restartQueuesAndNotificationsOnEmpty() {
|
||||||
|
log.info('restartQueuesAndNotificationsOnEmpty: restarting');
|
||||||
|
profileKeyResponseQueue.start();
|
||||||
|
lightSessionResetQueue.start();
|
||||||
|
onDecryptionErrorQueue.start();
|
||||||
|
onRetryRequestQueue.start();
|
||||||
|
window.Whisper.deliveryReceiptQueue.start();
|
||||||
|
notificationService.enable();
|
||||||
|
}
|
||||||
|
|
||||||
function isSocketOnline() {
|
function isSocketOnline() {
|
||||||
const socketStatus = window.getSocketStatus();
|
const socketStatus = window.getSocketStatus();
|
||||||
return (
|
return (
|
||||||
|
@ -1704,14 +1733,6 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
connectCount += 1;
|
connectCount += 1;
|
||||||
|
|
||||||
// To avoid a flood of operations before we catch up, we pause some queues.
|
|
||||||
profileKeyResponseQueue.pause();
|
|
||||||
lightSessionResetQueue.pause();
|
|
||||||
onDecryptionErrorQueue.pause();
|
|
||||||
onRetryRequestQueue.pause();
|
|
||||||
window.Whisper.deliveryReceiptQueue.pause();
|
|
||||||
notificationService.disable();
|
|
||||||
|
|
||||||
void window.Signal.Services.initializeGroupCredentialFetcher();
|
void window.Signal.Services.initializeGroupCredentialFetcher();
|
||||||
|
|
||||||
drop(AttachmentDownloadManager.start());
|
drop(AttachmentDownloadManager.start());
|
||||||
|
@ -1983,12 +2004,7 @@ export async function startApp(): Promise<void> {
|
||||||
// Start listeners here, after we get through our queue.
|
// Start listeners here, after we get through our queue.
|
||||||
UpdateKeysListener.init(window.Whisper.events, newVersion);
|
UpdateKeysListener.init(window.Whisper.events, newVersion);
|
||||||
|
|
||||||
profileKeyResponseQueue.start();
|
restartQueuesAndNotificationsOnEmpty();
|
||||||
lightSessionResetQueue.start();
|
|
||||||
onDecryptionErrorQueue.start();
|
|
||||||
onRetryRequestQueue.start();
|
|
||||||
window.Whisper.deliveryReceiptQueue.start();
|
|
||||||
notificationService.enable();
|
|
||||||
|
|
||||||
await onAppView;
|
await onAppView;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue