Skip to content

Commit

Permalink
Bootsplash logic in hybridapp (#132)
Browse files Browse the repository at this point in the history
* Implement ND bootsplash logic

* Rename param

* Adress review
  • Loading branch information
jnowakow authored Nov 7, 2024
1 parent 44dffc8 commit d976148
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ function Expensify() {
const isAuthenticated = useMemo(() => !!(session?.authToken ?? null), [session]);
const autoAuthState = useMemo(() => session?.autoAuthState ?? '', [session]);

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

Expand Down
6 changes: 5 additions & 1 deletion src/libs/actions/HybridApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ function setUseNewDotSignInPage(useNewDotSignInPage: boolean) {
Onyx.merge(ONYXKEYS.HYBRID_APP, {useNewDotSignInPage});
}

export {setOldDotSignInError, setIsSigningIn, setReadyToShowAuthScreens, setReadyToSwitchToClassicExperience, setShouldResetSigningInLogic, setUseNewDotSignInPage};
function setLoggedOutFromOldDot(loggedOutFromOldDot: boolean) {
Onyx.merge(ONYXKEYS.HYBRID_APP, {loggedOutFromOldDot});
}

export {setOldDotSignInError, setIsSigningIn, setReadyToShowAuthScreens, setReadyToSwitchToClassicExperience, setShouldResetSigningInLogic, setUseNewDotSignInPage, setLoggedOutFromOldDot};
7 changes: 4 additions & 3 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {hideContextMenu} from '@pages/home/report/ContextMenu/ReportActionContex
import * as App from '@userActions/App';
import {KEYS_TO_PRESERVE, openApp} from '@userActions/App';
import * as Device from '@userActions/Device';
import {setReadyToShowAuthScreens, setReadyToSwitchToClassicExperience, setUseNewDotSignInPage} from '@userActions/HybridApp';
import {setLoggedOutFromOldDot, setReadyToShowAuthScreens, setReadyToSwitchToClassicExperience, setUseNewDotSignInPage} from '@userActions/HybridApp';
import * as PriorityMode from '@userActions/PriorityMode';
import redirectToSignIn from '@userActions/SignInRedirect';
import Timing from '@userActions/Timing';
Expand Down Expand Up @@ -482,14 +482,14 @@ function signUpUser() {

function signInAfterTransitionFromOldDot(transitionURL: string) {
const [route, queryParams] = transitionURL.split('?');
const {useNewDotSignInPage, isSingleNewDotEntry} = queryParams
const {useNewDotSignInPage, isSingleNewDotEntry, loggedOutFromOldDot} = queryParams
? Object.fromEntries(
queryParams.split('&').map((param) => {
const [key, value] = param.split('=');
return [key, value];
}),
)
: {useNewDotSignInPage: undefined, isSingleNewDotEntry: undefined};
: {useNewDotSignInPage: undefined, isSingleNewDotEntry: undefined, loggedOutFromOldDot: undefined};

const clearOnyxBeforeSignIn = () => {
if (useNewDotSignInPage !== 'true') {
Expand All @@ -513,6 +513,7 @@ function signInAfterTransitionFromOldDot(transitionURL: string) {
clearOnyxBeforeSignIn()
.then(() => {
setUseNewDotSignInPage(useNewDotSignInPage === 'true');
setLoggedOutFromOldDot(loggedOutFromOldDot === 'true');
const useOldDot = 'true';
const dismissed = useNewDotSignInPage === 'true' ? useOldDot : 'false';
Onyx.multiSet({
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/HybridApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type HybridApp = {

/** */
shouldResetSigningInLogic?: boolean;

/** stores infromation if last log out was performed from OldDot */
loggedOutFromOldDot?: boolean;
};

export default HybridApp;

0 comments on commit d976148

Please sign in to comment.