diff --git a/src/libs/HybridApp.ts b/src/libs/HybridApp.ts index 1f5a0a768478..cd6b8893bdca 100644 --- a/src/libs/HybridApp.ts +++ b/src/libs/HybridApp.ts @@ -68,7 +68,13 @@ function handleChangeInHybridAppSignInFlow(hybridApp: OnyxEntry, tryN return; } - if (hybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED && tryNewDot !== undefined && !!credentials?.autoGeneratedLogin && !!credentials?.autoGeneratedPassword) { + if ( + hybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED && + !hybridApp?.signedInOnOldDot && + tryNewDot !== undefined && + !!credentials?.autoGeneratedLogin && + !!credentials?.autoGeneratedPassword + ) { Log.info(`[HybridApp] Performing sign-in${shouldUseOldApp(tryNewDot) ? '' : ' (in background)'} on OldDot side`); NativeModules.HybridAppModule.signInToOldDot( credentials.autoGeneratedLogin, @@ -78,6 +84,7 @@ function handleChangeInHybridAppSignInFlow(hybridApp: OnyxEntry, tryN getCurrentUserEmail() ?? '', activePolicyID ?? '', ); + HybridAppActions.setSignedInOnOldDot(true); if (shouldUseOldApp(tryNewDot)) { HybridAppActions.setUseNewDotSignInPage(false).then(() => { diff --git a/src/libs/actions/HybridApp/index.ts b/src/libs/actions/HybridApp/index.ts index db5c319b2bd0..5c20ce00b73d 100644 --- a/src/libs/actions/HybridApp/index.ts +++ b/src/libs/actions/HybridApp/index.ts @@ -30,6 +30,10 @@ function setUseNewDotSignInPage(useNewDotSignInPage: boolean) { return Onyx.merge(ONYXKEYS.HYBRID_APP, {useNewDotSignInPage}); } +function setSignedInOnOldDot(signedInOnOldDot: boolean) { + Onyx.merge(ONYXKEYS.HYBRID_APP, {signedInOnOldDot}); +} + /* * Starts HybridApp sign-in flow from the beginning. */ @@ -37,6 +41,7 @@ function resetSignInFlow() { Onyx.merge(ONYXKEYS.HYBRID_APP, { readyToShowAuthScreens: false, newDotSignInState: CONST.HYBRID_APP_SIGN_IN_STATE.NOT_STARTED, + signedInOnOldDot: false, }); } @@ -49,6 +54,7 @@ function prepareHybridAppAfterTransitionToNewDot(hybridApp: HybridApp) { ...hybridApp, readyToShowAuthScreens: false, newDotSignInState: CONST.HYBRID_APP_SIGN_IN_STATE.NOT_STARTED, + signedInOnOldDot: false, }); } @@ -59,4 +65,4 @@ function prepareHybridAppAfterTransitionToNewDot(hybridApp: HybridApp) { }); } -export {parseHybridAppSettings, setReadyToShowAuthScreens, setNewDotSignInState, resetSignInFlow, prepareHybridAppAfterTransitionToNewDot, setUseNewDotSignInPage}; +export {parseHybridAppSettings, setReadyToShowAuthScreens, setNewDotSignInState, resetSignInFlow, prepareHybridAppAfterTransitionToNewDot, setUseNewDotSignInPage, setSignedInOnOldDot}; diff --git a/src/types/onyx/HybridApp.ts b/src/types/onyx/HybridApp.ts index 54e0f7db7551..2fbb1504c81b 100644 --- a/src/types/onyx/HybridApp.ts +++ b/src/types/onyx/HybridApp.ts @@ -12,7 +12,7 @@ type HybridApp = { /** States whether we transitioned from OldDot to show only certain group of screens */ isSingleNewDotEntry?: boolean; - /** stores infromation if last log out was performed from OldDot */ + /** Stores information if last log out was performed from OldDot */ loggedOutFromOldDot?: boolean; /** */ @@ -20,6 +20,9 @@ type HybridApp = { /** Describes current stage of NewDot sign-in */ newDotSignInState?: ValueOf; + + /** Tells if OldDot sign-in was performed */ + signedInOnOldDot?: boolean; }; export default HybridApp;