From 51a9f627789e60f64f5fed4cca72a2feb494b287 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:55:42 -0600 Subject: [PATCH] Reorder checks in initialization sequence --- ts/background.ts | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index 11fa54c6bf..7696e316ee 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1410,8 +1410,6 @@ export async function startApp(): Promise { } } - window.dispatchEvent(new Event('storage_ready')); - void badgeImageFileDownloader.checkForFilesToDownload(); initializeExpiringMessageService(singleProtoJobQueue); @@ -1922,6 +1920,11 @@ export async function startApp(): Promise { return unlinkAndDisconnect(); } + if (!window.textsecure.storage.user.getPni()) { + log.error('PNI not captured during registration, unlinking softly'); + return unlinkAndDisconnect(); + } + if (connectCount === 1) { try { // Note: we always have to register our capabilities all at once, so we do this @@ -1939,11 +1942,6 @@ export async function startApp(): Promise { } } - if (!window.textsecure.storage.user.getPni()) { - log.error('PNI not captured during registration, unlinking softly'); - return unlinkAndDisconnect(); - } - if (firstRun === true && !areWePrimaryDevice) { if (!window.storage.get('accountEntropyPool')) { const lastSent = @@ -2028,23 +2026,18 @@ export async function startApp(): Promise { installed: true, })); - if (window.ConversationController.areWePrimaryDevice()) { - log.warn( - 'background/connect: We are primary device; not sending sticker pack sync' - ); - return; - } - - log.info('firstRun: requesting stickers', operations.length); - try { - await singleProtoJobQueue.add( - MessageSender.getStickerPackSync(operations) - ); - } catch (error) { - log.error( - 'connect: Failed to queue sticker sync message', - Errors.toLogFormat(error) - ); + if (!window.ConversationController.areWePrimaryDevice()) { + log.info('firstRun: requesting stickers', operations.length); + try { + await singleProtoJobQueue.add( + MessageSender.getStickerPackSync(operations) + ); + } catch (error) { + log.error( + 'connect: Failed to queue sticker sync message', + Errors.toLogFormat(error) + ); + } } }