[Session] Extract selectAccount out (#3812)
This commit is contained in:
parent
5ec945b762
commit
1a07e23192
7 changed files with 48 additions and 42 deletions
|
@ -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]}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue