Skip to content

Commit

Permalink
Implement ND bootsplash logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jnowakow committed Nov 6, 2024
1 parent db0d806 commit 5409a5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function Expensify() {
const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false});
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);
const [useNewDotSignInPage] = useOnyx(ONYXKEYS.USE_NEWDOT_SIGN_IN_PAGE);
const [useLoggedOutFromOldDot] = useOnyx(ONYXKEYS.LOGGED_OUT_FROM_OLDDOT);

useEffect(() => {
if (!account?.needsTwoFactorAuthSetup || account.requiresTwoFactorAuth) {
Expand All @@ -117,11 +118,13 @@ function Expensify() {
const isAuthenticated = useMemo(() => !!(session?.authToken ?? null), [session]);
const autoAuthState = useMemo(() => session?.autoAuthState ?? '', [session]);

const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom;
const isHybridApp = !!NativeModules.HybridAppModule;

const shouldInit = isHybridApp ? !useLoggedOutFromOldDot && isNavigationReady && hasAttemptedToOpenPublicRoom : isNavigationReady && hasAttemptedToOpenPublicRoom;
const shouldHideSplash =
shouldInit &&
(NativeModules.HybridAppModule
? splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN && (isAuthenticated || useNewDotSignInPage)
(isHybridApp
? splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN && (isAuthenticated || !!useNewDotSignInPage)
: splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE);

const initializeClient = () => {
Expand Down
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ const ONYXKEYS = {
/** Stores the information if HybridApp uses NewDot's sign in flow */
USE_NEWDOT_SIGN_IN_PAGE: 'useNewDotSignInPage',

/** Stores the information if user logged out from OldDot when using hybrid app */
LOGGED_OUT_FROM_OLDDOT: 'loggedOutFromOldDot',

HYBRID_APP: 'hybridApp',

/** Collection Keys */
Expand Down Expand Up @@ -1027,6 +1030,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.SHOULD_SHOW_SAVED_SEARCH_RENAME_TOOLTIP]: boolean;
[ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES]: Record<string, string>;
[ONYXKEYS.USE_NEWDOT_SIGN_IN_PAGE]: boolean;
[ONYXKEYS.LOGGED_OUT_FROM_OLDDOT]: boolean;
[ONYXKEYS.HYBRID_APP]: OnyxTypes.HybridApp;
};
type OnyxValues = OnyxValuesMapping & OnyxCollectionValuesMapping & OnyxFormValuesMapping & OnyxFormDraftValuesMapping;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ function signInAfterTransitionFromOldDot(transitionURL: string) {
)
: {};

const {useNewDotSignInPage, isSingleNewDotEntry} = queryParamsObject;
const {useNewDotSignInPage, isSingleNewDotEntry, loggedOut} = queryParamsObject;

const clearOnyxBeforeSignIn = () => {
if (useNewDotSignInPage !== 'true') {
Expand All @@ -513,6 +513,7 @@ function signInAfterTransitionFromOldDot(transitionURL: string) {
.then(() =>
Onyx.multiSet({
[ONYXKEYS.USE_NEWDOT_SIGN_IN_PAGE]: useNewDotSignInPage === 'true',
[ONYXKEYS.LOGGED_OUT_FROM_OLDDOT]: loggedOut === 'true',
[ONYXKEYS.NVP_TRYNEWDOT]: {classicRedirect: {dismissed: 'true'}}, // This data is mocked and should be returned by BeginSignUp/SignInUser API commands
}),
)
Expand Down

0 comments on commit 5409a5d

Please sign in to comment.