Skip to content

Commit

Permalink
[Session] Reset global agent on expire (#3838)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored May 3, 2024
1 parent cdf7a19 commit 1e484c6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/state/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
if (expired) {
logger.warn(`session: expired`)
emitSessionDropped()
__globalAgent = PUBLIC_BSKY_AGENT
configureModerationForGuest()
setState(s => ({
accounts: s.accounts,
currentAgentState: {
agent: PUBLIC_BSKY_AGENT,
did: undefined,
},
needsPersist: true,
}))
}

/*
Expand Down Expand Up @@ -175,12 +185,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
refreshedAccount,
...s.accounts.filter(a => a.did !== refreshedAccount.did),
],
currentAgentState: expired
? {
agent: PUBLIC_BSKY_AGENT,
did: undefined,
}
: s.currentAgentState,
currentAgentState: s.currentAgentState,
needsPersist: true,
}
})
Expand Down

0 comments on commit 1e484c6

Please sign in to comment.