Ensure inbox is shown when registered device is offline

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2024-04-16 15:04:09 -05:00 committed by GitHub
parent 50f323fd65
commit 7dfe4cdf74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1538,24 +1538,38 @@ export async function startApp(): Promise<void> {
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);