From 97b54b51c6580737a561b48125af2884b23548f3 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Sat, 9 Dec 2023 17:10:12 -0600 Subject: [PATCH] Add back isInitialLoad to session (#2155) --- src/App.native.tsx | 5 ++++- src/App.web.tsx | 5 ++++- src/state/session/index.tsx | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/App.native.tsx b/src/App.native.tsx index 538e9b32..d11d05e7 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -39,7 +39,7 @@ SplashScreen.preventAutoHideAsync() function InnerApp() { const colorMode = useColorMode() - const {currentAccount} = useSession() + const {isInitialLoad, currentAccount} = useSession() const {resumeSession} = useSessionApi() // init @@ -53,6 +53,9 @@ function InnerApp() { resumeSession(account) }, [resumeSession]) + // wait for session to resume + if (isInitialLoad) return null + return ( ({ + isInitialLoad: true, isSwitchingAccounts: false, accounts: [], currentAccount: undefined, @@ -150,6 +152,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { const queryClient = useQueryClient() const isDirty = React.useRef(false) const [state, setState] = React.useState({ + isInitialLoad: true, isSwitchingAccounts: false, accounts: persisted.get('session').accounts, currentAccount: undefined, // assume logged out to start @@ -434,6 +437,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) { } } catch (e) { logger.error(`session: resumeSession failed`, {error: e}) + } finally { + setState(s => ({ + ...s, + isInitialLoad: false, + })) } }, [initSession],