From 6e9320163a512299f549a8c08a81fb6f1bdb2fd7 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 3 May 2024 04:16:51 +0100 Subject: [PATCH] [Session] Remove imperative agent restoration call Co-authored-by: dan --- src/state/session/index.tsx | 45 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index b9d67f2e0a..4adccfe67e 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -332,35 +332,22 @@ export function Provider({children}: React.PropsWithChildren<{}>) { if (isSessionExpired(account)) { logger.debug(`session: attempting to resume using previous session`) - try { - const freshAccount = await resumeSessionWithFreshAccount() - __globalAgent = agent - await fetchingGates - setState(s => { - return { - accounts: [ - freshAccount, - ...s.accounts.filter(a => a.did !== freshAccount.did), - ], - currentAgentState: { - did: freshAccount.did, - agent: agent, - }, - 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. - } + const freshAccount = await resumeSessionWithFreshAccount() + __globalAgent = agent + await fetchingGates + setState(s => { + return { + accounts: [ + freshAccount, + ...s.accounts.filter(a => a.did !== freshAccount.did), + ], + currentAgentState: { + did: freshAccount.did, + agent: agent, + }, + needsPersist: true, + } + }) } else { logger.debug(`session: attempting to reuse previous session`)