Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add back isInitialLoad to session (#2155)

authored by

Eric Bailey and committed by
GitHub
97b54b51 6b3eb401

+16 -2
+4 -1
src/App.native.tsx
··· 39 39 40 40 function InnerApp() { 41 41 const colorMode = useColorMode() 42 - const {currentAccount} = useSession() 42 + const {isInitialLoad, currentAccount} = useSession() 43 43 const {resumeSession} = useSessionApi() 44 44 45 45 // init ··· 52 52 const account = persisted.get('session').currentAccount 53 53 resumeSession(account) 54 54 }, [resumeSession]) 55 + 56 + // wait for session to resume 57 + if (isInitialLoad) return null 55 58 56 59 return ( 57 60 <React.Fragment
+4 -1
src/App.web.tsx
··· 30 30 import * as persisted from '#/state/persisted' 31 31 32 32 function InnerApp() { 33 - const {currentAccount} = useSession() 33 + const {isInitialLoad, currentAccount} = useSession() 34 34 const {resumeSession} = useSessionApi() 35 35 const colorMode = useColorMode() 36 36 ··· 39 39 const account = persisted.get('session').currentAccount 40 40 resumeSession(account) 41 41 }, [resumeSession]) 42 + 43 + // wait for session to resume 44 + if (isInitialLoad) return null 42 45 43 46 return ( 44 47 <React.Fragment
+8
src/state/session/index.tsx
··· 28 28 export type SessionAccount = persisted.PersistedAccount 29 29 30 30 export type SessionState = { 31 + isInitialLoad: boolean 31 32 isSwitchingAccounts: boolean 32 33 accounts: SessionAccount[] 33 34 currentAccount: SessionAccount | undefined ··· 75 76 } 76 77 77 78 const StateContext = React.createContext<StateContext>({ 79 + isInitialLoad: true, 78 80 isSwitchingAccounts: false, 79 81 accounts: [], 80 82 currentAccount: undefined, ··· 150 152 const queryClient = useQueryClient() 151 153 const isDirty = React.useRef(false) 152 154 const [state, setState] = React.useState<SessionState>({ 155 + isInitialLoad: true, 153 156 isSwitchingAccounts: false, 154 157 accounts: persisted.get('session').accounts, 155 158 currentAccount: undefined, // assume logged out to start ··· 434 437 } 435 438 } catch (e) { 436 439 logger.error(`session: resumeSession failed`, {error: e}) 440 + } finally { 441 + setState(s => ({ 442 + ...s, 443 + isInitialLoad: false, 444 + })) 437 445 } 438 446 }, 439 447 [initSession],