[Session] Remove imperative agent restoration call

Co-authored-by: dan <dan.abramov@gmail.com>
This commit is contained in:
Eric Bailey
2024-05-03 04:16:51 +01:00
committed by Dan Abramov
parent cdf7a1957a
commit 6e9320163a
+16 -29
View File
@@ -332,35 +332,22 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
if (isSessionExpired(account)) { if (isSessionExpired(account)) {
logger.debug(`session: attempting to resume using previous session`) logger.debug(`session: attempting to resume using previous session`)
try { const freshAccount = await resumeSessionWithFreshAccount()
const freshAccount = await resumeSessionWithFreshAccount() __globalAgent = agent
__globalAgent = agent await fetchingGates
await fetchingGates setState(s => {
setState(s => { return {
return { accounts: [
accounts: [ freshAccount,
freshAccount, ...s.accounts.filter(a => a.did !== freshAccount.did),
...s.accounts.filter(a => a.did !== freshAccount.did), ],
], currentAgentState: {
currentAgentState: { did: freshAccount.did,
did: freshAccount.did, agent: agent,
agent: agent, },
}, needsPersist: true,
needsPersist: true, }
} })
})
} catch (e) {
/*
* Note: `agent.persistSession` is also called when this fails, and
* we handle that failure via `createPersistSessionHandler`
*/
logger.info(`session: resumeSessionWithFreshAccount failed`, {
message: e,
})
__globalAgent = PUBLIC_BSKY_AGENT
// TODO: This needs a setState.
}
} else { } else {
logger.debug(`session: attempting to reuse previous session`) logger.debug(`session: attempting to reuse previous session`)