From b86c3b486f2e126fe887733c9e8ef6856cd67e91 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 2 May 2024 21:55:50 +0100 Subject: [PATCH] Improve account switcher pending state (#3827) * Protect against races * Reduce UI jank when switching accounts * Add pending state to selected account * Disable presses while pending --- src/components/AccountList.tsx | 15 +-- src/components/dialogs/SwitchAccount.tsx | 4 +- src/lib/hooks/useAccountSwitcher.ts | 22 +++-- src/screens/Login/ChooseAccountForm.tsx | 22 ++++- src/view/screens/Settings/index.tsx | 121 ++++++++++++----------- 5 files changed, 105 insertions(+), 79 deletions(-) diff --git a/src/components/AccountList.tsx b/src/components/AccountList.tsx index 76596df3..7d696801 100644 --- a/src/components/AccountList.tsx +++ b/src/components/AccountList.tsx @@ -16,12 +16,12 @@ export function AccountList({ onSelectAccount, onSelectOther, otherLabel, - isSwitchingAccounts, + pendingDid, }: { onSelectAccount: (account: SessionAccount) => void onSelectOther: () => void otherLabel?: string - isSwitchingAccounts: boolean + pendingDid: string | null }) { const {currentAccount, accounts} = useSession() const t = useTheme() @@ -33,6 +33,7 @@ export function AccountList({ return ( @@ -52,7 +54,7 @@ export function AccountList({