Skip to content

Commit

Permalink
Update clear account behavior, ensure agent is set (#1881)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored Nov 13, 2023
1 parent b445c15 commit 37a2204
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/state/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
}),
)

setState(s => ({...s, agent}))
upsertAccount(account)

logger.debug(
Expand Down Expand Up @@ -373,9 +374,14 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
[setState, initSession],
)

/**
* Clears the `currentAccount` from session. Typically used to drop the user
* back to the sign-in page.
*/
const clearCurrentAccount = React.useCallback(() => {
setStateAndPersist(s => ({
...s,
agent: PUBLIC_BSKY_AGENT,
currentAccount: undefined,
}))
}, [setStateAndPersist])
Expand Down Expand Up @@ -425,10 +431,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
logger.DebugContext.session,
)

logout()
clearCurrentAccount()
}
})
}, [state, logout, initSession])
}, [state, clearCurrentAccount, initSession])

const stateContext = React.useMemo(
() => ({
Expand Down

0 comments on commit 37a2204

Please sign in to comment.