Session fixes, pt. 1 (#3762)

* Update persisted schema for new source of truth, implement in existing session

(cherry picked from commit b1e5f12baee932721d66c60dd51c981b46b0c274)

* Improve toasts, log caught error, during switch account

(cherry picked from commit fe0d1507063d2e532b7b1a447670b689292d1dc3)

* Handle thrown errors from initSession during login

(cherry picked from commit 2c85c045917e923901284b9ba310a82e28f37b5c)

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
dan 2024-04-30 17:38:05 +01:00 committed by GitHub
parent 4de78fb69e
commit 2b7d796ca9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 24 deletions

View file

@ -5,6 +5,7 @@ import {useLingui} from '@lingui/react'
import {useAnalytics} from '#/lib/analytics/analytics'
import {logEvent} from '#/lib/statsig/statsig'
import {logger} from '#/logger'
import {SessionAccount, useSession, useSessionApi} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import * as Toast from '#/view/com/util/Toast'
@ -38,15 +39,22 @@ export const ChooseAccountForm = ({
setShowLoggedOut(false)
Toast.show(_(msg`Already signed in as @${account.handle}`))
} else {
await initSession(account)
logEvent('account:loggedIn', {
logContext: 'ChooseAccountForm',
withPassword: false,
})
track('Sign In', {resumedSession: true})
setTimeout(() => {
Toast.show(_(msg`Signed in as @${account.handle}`))
}, 100)
try {
await initSession(account)
logEvent('account:loggedIn', {
logContext: 'ChooseAccountForm',
withPassword: false,
})
track('Sign In', {resumedSession: true})
setTimeout(() => {
Toast.show(_(msg`Signed in as @${account.handle}`))
}, 100)
} catch (e: any) {
logger.error('choose account: initSession failed', {
message: e.message,
})
onSelectAccount(account)
}
}
} else {
onSelectAccount(account)