From 1a98d509483789c6406964128b8339d1cc375daa Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:46:51 -0400 Subject: [PATCH] Ensure we register messageReceiver only after setup is complete --- ts/background.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index 9eec9aeac0b0..400624bb36c7 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1554,14 +1554,11 @@ export async function startApp(): Promise { window.Whisper.events.on('online', () => { log.info('background: online'); - - strictAssert(server !== undefined, 'WebAPI not initialized'); strictAssert( messageReceiver !== undefined, 'MessageReceiver not initialized' ); messageReceiver.reset(); - server.registerRequestHandler(messageReceiver); // The first call to connect should be done via start(), ensuring that the app is // ready first @@ -1577,9 +1574,6 @@ export async function startApp(): Promise { drop(AttachmentDownloads.stop()); drop(messageReceiver?.drain()); - if (messageReceiver) { - server?.unregisterRequestHandler(messageReceiver); - } if (connectCount === 0) { log.info('background: offline, never connected, showing inbox'); @@ -1675,6 +1669,12 @@ export async function startApp(): Promise { void window.Signal.Services.initializeGroupCredentialFetcher(); + strictAssert( + messageReceiver !== undefined, + 'MessageReceiver not initialized' + ); + server.registerRequestHandler(messageReceiver); + drop( AttachmentDownloads.start({ logger: log,