Update clear account behavior, ensure agent is set (#1881)
parent
b445c15cc9
commit
37a2204483
|
@ -178,6 +178,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
setState(s => ({...s, agent}))
|
||||||
upsertAccount(account)
|
upsertAccount(account)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
@ -373,9 +374,14 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
[setState, initSession],
|
[setState, initSession],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the `currentAccount` from session. Typically used to drop the user
|
||||||
|
* back to the sign-in page.
|
||||||
|
*/
|
||||||
const clearCurrentAccount = React.useCallback(() => {
|
const clearCurrentAccount = React.useCallback(() => {
|
||||||
setStateAndPersist(s => ({
|
setStateAndPersist(s => ({
|
||||||
...s,
|
...s,
|
||||||
|
agent: PUBLIC_BSKY_AGENT,
|
||||||
currentAccount: undefined,
|
currentAccount: undefined,
|
||||||
}))
|
}))
|
||||||
}, [setStateAndPersist])
|
}, [setStateAndPersist])
|
||||||
|
@ -425,10 +431,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
logger.DebugContext.session,
|
logger.DebugContext.session,
|
||||||
)
|
)
|
||||||
|
|
||||||
logout()
|
clearCurrentAccount()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [state, logout, initSession])
|
}, [state, clearCurrentAccount, initSession])
|
||||||
|
|
||||||
const stateContext = React.useMemo(
|
const stateContext = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
|
Loading…
Reference in New Issue