about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/App.native.tsx5
-rw-r--r--src/App.web.tsx5
-rw-r--r--src/state/session/index.tsx8
3 files changed, 16 insertions, 2 deletions
diff --git a/src/App.native.tsx b/src/App.native.tsx
index 538e9b32d..d11d05e70 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 (
     <React.Fragment
       // Resets the entire tree below when it changes:
diff --git a/src/App.web.tsx b/src/App.web.tsx
index ef172705e..6c67dc28b 100644
--- a/src/App.web.tsx
+++ b/src/App.web.tsx
@@ -30,7 +30,7 @@ import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unre
 import * as persisted from '#/state/persisted'
 
 function InnerApp() {
-  const {currentAccount} = useSession()
+  const {isInitialLoad, currentAccount} = useSession()
   const {resumeSession} = useSessionApi()
   const colorMode = useColorMode()
 
@@ -40,6 +40,9 @@ function InnerApp() {
     resumeSession(account)
   }, [resumeSession])
 
+  // wait for session to resume
+  if (isInitialLoad) return null
+
   return (
     <React.Fragment
       // Resets the entire tree below when it changes:
diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx
index d4cd2fcd2..56208bc70 100644
--- a/src/state/session/index.tsx
+++ b/src/state/session/index.tsx
@@ -28,6 +28,7 @@ export function getAgent() {
 export type SessionAccount = persisted.PersistedAccount
 
 export type SessionState = {
+  isInitialLoad: boolean
   isSwitchingAccounts: boolean
   accounts: SessionAccount[]
   currentAccount: SessionAccount | undefined
@@ -75,6 +76,7 @@ export type ApiContext = {
 }
 
 const StateContext = React.createContext<StateContext>({
+  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<SessionState>({
+    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],