[Session] Extract selectAccount out (#3812)

This commit is contained in:
dan 2024-05-02 18:25:09 +01:00 committed by GitHub
parent 5ec945b762
commit 1a07e23192
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 48 additions and 42 deletions

View file

@ -22,6 +22,7 @@ export const ChooseAccountForm = ({
onSelectAccount: (account?: SessionAccount) => void
onPressBack: () => void
}) => {
const [isSwitchingAccounts, setIsSwitchingAccounts] = React.useState(false)
const {track, screen} = useAnalytics()
const {_} = useLingui()
const {currentAccount} = useSession()
@ -40,6 +41,7 @@ export const ChooseAccountForm = ({
Toast.show(_(msg`Already signed in as @${account.handle}`))
} else {
try {
setIsSwitchingAccounts(true)
await initSession(account)
logEvent('account:loggedIn', {
logContext: 'ChooseAccountForm',
@ -54,6 +56,8 @@ export const ChooseAccountForm = ({
message: e.message,
})
onSelectAccount(account)
} finally {
setIsSwitchingAccounts(false)
}
}
} else {
@ -74,6 +78,7 @@ export const ChooseAccountForm = ({
<AccountList
onSelectAccount={onSelect}
onSelectOther={() => onSelectAccount()}
isSwitchingAccounts={isSwitchingAccounts}
/>
</View>
<View style={[a.flex_row]}>