Skip to content

Commit 5e21bd5

Browse files
committed
improve splash screen hiding logic
1 parent 6eb0c44 commit 5e21bd5

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

src/Expensify.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,21 @@ function Expensify() {
117117
const isAuthenticated = useIsAuthenticated();
118118
const autoAuthState = useMemo(() => session?.autoAuthState ?? '', [session]);
119119

120-
const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom && !!preferredLocale;
120+
const isSplashReadyToBeHidden = splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN;
121121
const isSplashVisible = splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE;
122-
const isHybridAppReady = splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN && (isAuthenticated || !!hybridApp?.useNewDotSignInPage);
123-
const shouldHideSplash = shouldInit && (CONFIG.IS_HYBRID_APP ? isHybridAppReady : isSplashVisible);
122+
123+
const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom && !!preferredLocale;
124+
const shouldHideSplash = (isSplashReadyToBeHidden || isSplashVisible) && shouldInit && !hybridApp?.loggedOutFromOldDot;
125+
126+
// This effect is closing OldDot sign out modal based on splash screen state
127+
useEffect(() => {
128+
if (!isSplashReadyToBeHidden || !shouldInit || !hybridApp?.loggedOutFromOldDot) {
129+
return;
130+
}
131+
132+
setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN);
133+
HybridAppModule.clearOldDotAfterSignOut();
134+
}, [hybridApp?.loggedOutFromOldDot, isSplashReadyToBeHidden, setSplashScreenState, shouldInit, splashScreenState]);
124135

125136
const initializeClient = () => {
126137
if (!Visibility.isVisible()) {

src/HybridAppHandler.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ function HybridAppHandler() {
2929
}
3030

3131
const parsedHybridAppSettings = parseHybridAppSettings(hybridAppSettings);
32-
3332
setupNewDotAfterTransitionFromOldDot(parsedHybridAppSettings, tryNewDot).then(() => {
34-
if (parsedHybridAppSettings.hybridApp?.loggedOutFromOldDot) {
35-
setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN);
36-
} else if (splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE) {
37-
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
33+
if (splashScreenState !== CONST.BOOT_SPLASH_STATE.VISIBLE) {
34+
return;
3835
}
36+
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
3937
});
4038
});
4139
}, [isLoading, setSplashScreenState, splashScreenState, tryNewDot]);

src/pages/signin/SignInPage.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import HybridAppModule from '@expensify/react-native-hybrid-app';
21
import {Str} from 'expensify-common';
32
import React, {forwardRef, useEffect, useImperativeHandle, useRef, useState} from 'react';
43
import type {ForwardedRef} from 'react';
@@ -22,7 +21,6 @@ import Performance from '@libs/Performance';
2221
import Visibility from '@libs/Visibility';
2322
import {setLocale} from '@userActions/App';
2423
import {clearSignInData} from '@userActions/Session';
25-
import CONFIG from '@src/CONFIG';
2624
import CONST from '@src/CONST';
2725
import ONYXKEYS from '@src/ONYXKEYS';
2826
import ROUTES from '@src/ROUTES';
@@ -185,7 +183,6 @@ function SignInPage({shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: F
185183
// We need to show "Another login page is opened" message if the page isn't active and visible
186184
// eslint-disable-next-line rulesdir/no-negated-variables
187185
const shouldShowAnotherLoginPageOpenedMessage = Visibility.isVisible() && !isClientTheLeader;
188-
const [hybridApp] = useOnyx(ONYXKEYS.HYBRID_APP, {canBeMissing: true});
189186

190187
useEffect(() => Performance.measureTTI(), []);
191188

@@ -306,15 +303,6 @@ function SignInPage({shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: F
306303
navigateBack,
307304
}));
308305

309-
// This effect is closing OldDot sign out modal when SignInPage appears
310-
// It can't be performed in any other place because there would be an empty screen for a while
311-
useEffect(() => {
312-
if (!CONFIG.IS_HYBRID_APP || !hybridApp?.loggedOutFromOldDot) {
313-
return;
314-
}
315-
HybridAppModule.clearOldDotAfterSignOut();
316-
}, [hybridApp?.loggedOutFromOldDot]);
317-
318306
return (
319307
// Bottom SafeAreaView is removed so that login screen svg displays correctly on mobile.
320308
// The SVG should flow under the Home Indicator on iOS.

0 commit comments

Comments
 (0)