Skip to content

Commit

Permalink
move ready to be hidden to InitialURLContextProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
war-in committed Sep 2, 2024
1 parent a3aa755 commit 320de61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/components/InitialURLContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {createContext, useEffect, useState} from 'react';
import type {ReactNode} from 'react';
import {Linking} from 'react-native';
import {signInAfterTransitionFromOldDot} from '@libs/actions/Session';
import CONST from '@src/CONST';
import type {Route} from '@src/ROUTES';
import {useSplashScreenStateContext} from '@src/SplashScreenStateContext';

Expand All @@ -22,8 +23,9 @@ function InitialURLContextProvider({children, url}: InitialURLContextProviderPro

useEffect(() => {
if (url) {
signInAfterTransitionFromOldDot(url, setSplashScreenState);
signInAfterTransitionFromOldDot(url);
setInitialURL(url);
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
return;
}
Linking.getInitialURL().then((initURL) => {
Expand Down
8 changes: 2 additions & 6 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ function signUpUser() {
API.write(WRITE_COMMANDS.SIGN_UP_USER, params, {optimisticData, successData, failureData});
}

function signInAfterTransitionFromOldDot(transitionURL: string, setSplashScreenState: React.Dispatch<React.SetStateAction<ValueOf<typeof CONST.BOOT_SPLASH_STATE>>>) {
function signInAfterTransitionFromOldDot(transitionURL: string) {
const queryParams = transitionURL.split('?')[1];

const {email, authToken, accountID, autoGeneratedLogin, autoGeneratedPassword, shouldClearOnyxOnStart} = Object.fromEntries(
Expand All @@ -479,12 +479,8 @@ function signInAfterTransitionFromOldDot(transitionURL: string, setSplashScreenS
};

if (shouldClearOnyxOnStart === 'true') {
Onyx.clear(KEYS_TO_PRESERVE).then(() => {
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
setSessionDataAndOpenApp();
});
Onyx.clear(KEYS_TO_PRESERVE).then(setSessionDataAndOpenApp);
} else {
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
setSessionDataAndOpenApp();
}
}
Expand Down

0 comments on commit 320de61

Please sign in to comment.