diff --git a/src/App.tsx b/src/App.tsx index 0c4ba61c..df2c0285 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ // eslint-disable-next-line import/no-unresolved -import React from 'react'; +import React, { useCallback } from 'react'; import { RecoilRoot } from 'recoil'; import { NavigationContainer } from '@react-navigation/native'; import RootNavigator from 'navigation/RootNavigator'; @@ -14,6 +14,8 @@ import useCheckKeyChainIntegrity from 'hooks/dataintegrity/useCheckKeyChainInteg import useInitNotifications from 'hooks/notifications/useInitNotifications'; import { getCachedUriAction, isUriActionPending, onCachedUriActionChange } from 'lib/UriActions'; import { useSetUriAction } from '@recoil/uriaction'; +import { useAppState, useSetAppState } from '@recoil/appState'; +import { useSetting } from '@recoil/settings'; const AppLockLogic = () => { useLockApplicationOnBlur(); @@ -24,19 +26,27 @@ const AppLockLogic = () => { const Navigation = () => { const setUriAction = useSetUriAction(); + const { ready } = useAppState(); + const setAppState = useSetAppState(); + const showUnlockApplicationScreen = useSetting('autoAppLock'); React.useEffect(() => { - if (isUriActionPending()) { + if (ready && isUriActionPending()) { const action = getCachedUriAction(); if (action) { setUriAction(action); } } return onCachedUriActionChange(setUriAction); - }, [setUriAction]); + }, [setUriAction, ready]); + + const onNavigatorReady = useCallback(() => { + RNBootSplash.hide({ fade: true, duration: 500 }); + setAppState((state) => ({ ...state, ready: true, locked: showUnlockApplicationScreen })); + }, [setAppState, showUnlockApplicationScreen]); return ( - RNBootSplash.hide({ fade: true, duration: 500 })}> + diff --git a/src/recoil/appState.ts b/src/recoil/appState.ts index e4700122..3c2a5ef5 100644 --- a/src/recoil/appState.ts +++ b/src/recoil/appState.ts @@ -5,6 +5,7 @@ const appStateAtom = atom({ key: 'appState', default: { locked: false, + ready: false, noSplashScreen: false, noLockOnBackground: false, lastObBlur: undefined, diff --git a/src/types/appState.ts b/src/types/appState.ts index b66fdd24..3de41009 100644 --- a/src/types/appState.ts +++ b/src/types/appState.ts @@ -9,6 +9,11 @@ export interface AppState { * with the biometrics. */ readonly locked: boolean; + /** + * Tells if the application is ready to and the + * splash screen has been hidden. + */ + readonly ready: boolean; /** * Tells if the application shouldn't lock when receiving the next on * background AppState event.