[Session] Align state and global agent switchpoints (#3845)

* Adopt synced accounts unconditionally

* Remove try/catch around resuming session

* Move to login form on resume failure

* Restructure code flow for easier reading

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
dan 2024-05-03 17:57:09 +01:00 committed by GitHub
parent 85b34418ef
commit 4a2d4253e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 70 deletions

View file

@ -15,7 +15,7 @@ export function useAccountSwitcher() {
const [pendingDid, setPendingDid] = useState<string | null>(null)
const {_} = useLingui()
const {track} = useAnalytics()
const {initSession, clearCurrentAccount} = useSessionApi()
const {initSession} = useSessionApi()
const {requestSwitchToAccount} = useLoggedOutViewControls()
const onPressSwitchAccount = useCallback(
@ -53,19 +53,11 @@ export function useAccountSwitcher() {
logger.error(`switch account: selectAccount failed`, {
message: e.message,
})
clearCurrentAccount() // back user out to login
} finally {
setPendingDid(null)
}
},
[
_,
track,
clearCurrentAccount,
initSession,
requestSwitchToAccount,
pendingDid,
],
[_, track, initSession, requestSwitchToAccount, pendingDid],
)
return {onPressSwitchAccount, pendingDid}