diff --git a/src/features/auth/AccountSwitcher.tsx b/src/features/auth/AccountSwitcher.tsx index 702bd5c860..7eb4eee6a1 100644 --- a/src/features/auth/AccountSwitcher.tsx +++ b/src/features/auth/AccountSwitcher.tsx @@ -30,7 +30,7 @@ import { setAccounts } from "./authSlice"; type AccountSwitcherProps = { onDismiss: (data?: string, role?: string) => void; - onSelectAccount: (account: string) => Promise; + onSelectAccount: ((account: string) => Promise) | void; showGuest?: boolean; activeHandle?: string; } & ( @@ -130,10 +130,13 @@ function AccountSwitcherContents({ const old = selectedAccount; setSelectedAccount(e.target.value); - const selectionChangePromise = onSelectAccount(e.target.value); + const selectionChangePromise = onSelectAccount?.(e.target.value); // Bail on rendering the loading indicator - if (await isPromiseResolvedByPaint(selectionChangePromise)) { + if ( + !selectionChangePromise || + (await isPromiseResolvedByPaint(selectionChangePromise)) + ) { onDismiss(); return; } diff --git a/src/helpers/promise.ts b/src/helpers/promise.ts index b50f68d86a..1a6bbb6c18 100644 --- a/src/helpers/promise.ts +++ b/src/helpers/promise.ts @@ -8,5 +8,6 @@ export function isPromiseResolvedByPaint( resolve(false); }); }), - ]); + // If promise rejected, it's still resolved by paint + ]).catch(() => true); }