From da58071104ac16f841571f1cec25fd6574cd930f Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 13 Nov 2023 09:46:20 -0600 Subject: [PATCH] Update clear account behavior, ensure agent is set --- src/state/session/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index d0ca101378..e01e841f68 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -178,6 +178,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { }), ) + setState(s => ({...s, agent})) upsertAccount(account) logger.debug( @@ -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]) @@ -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( () => ({