diff --git a/ts/background.ts b/ts/background.ts index 7db5ebe1ff0..847d4b1d100 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1538,24 +1538,38 @@ export async function startApp(): Promise { window.Whisper.events.on('online', onOnline); const onOffline = () => { - log.info('background: offline'); + const { hasInitialLoadCompleted, appView } = + window.reduxStore.getState().app; + + const hasAppEverBeenRegistered = Registration.everDone(); + + log.info('background: offline', { + connectCount, + hasInitialLoadCompleted, + appView, + hasAppEverBeenRegistered, + }); drop(challengeHandler?.onOffline()); drop(AttachmentDownloads.stop()); drop(messageReceiver?.drain()); - if (connectCount === 0) { - log.info('background: offline, never connected, showing inbox'); - - drop(onEmpty()); // this ensures that the loading screen is dismissed - - // Switch to inbox view even if contact sync is still running + if (hasAppEverBeenRegistered) { if ( window.reduxStore.getState().app.appView === AppViewType.Installer ) { - log.info('background: offline, opening inbox'); + log.info( + 'background: offline, but app has been registered before; opening inbox' + ); window.reduxActions.app.openInbox(); } + + if (!hasInitialLoadCompleted) { + log.info( + 'background: offline; initial load not completed; triggering onEmpty' + ); + drop(onEmpty()); // this ensures that the inbox loading progress bar is dismissed + } } }; window.Whisper.events.on('offline', onOffline);