[Session] Convert account to session data explicitly (#4446)

* Extract a variable

* Extract sessionAccountToSession

* Convert account to session data on assignment
This commit is contained in:
dan
2024-06-19 02:47:50 +03:00
committed by GitHub
parent 5159495274
commit 7ddbc392c3
2 changed files with 24 additions and 17 deletions
+3 -2
View File
@@ -14,6 +14,7 @@ import {
createAgentAndCreateAccount,
createAgentAndLogin,
createAgentAndResume,
sessionAccountToSession,
} from './agent'
import {getInitialState, reducer} from './reducer'
@@ -175,8 +176,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
if (syncedAccount.did !== state.currentAgentState.did) {
resumeSession(syncedAccount)
} else {
// @ts-ignore we checked for `refreshJwt` above
state.currentAgentState.agent.session = syncedAccount
const agent = state.currentAgentState.agent as BskyAgent
agent.session = sessionAccountToSession(syncedAccount)
}
}
})