Add back isInitialLoad to session (#2155)
This commit is contained in:
parent
6b3eb401b0
commit
97b54b51c6
3 changed files with 16 additions and 2 deletions
|
@ -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],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue