From 499021229a03b3414d6a1f2909c6e7d7db5e4b2f Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 10 Nov 2023 08:53:23 -0600 Subject: [PATCH] Remove error states, just best effort --- src/view/com/auth/login/ChooseAccountForm.tsx | 9 +++------ src/view/com/modals/SwitchAccount.tsx | 9 +++------ src/view/screens/Settings.tsx | 11 ++++------- src/view/shell/desktop/LeftNav.tsx | 14 ++++---------- 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/view/com/auth/login/ChooseAccountForm.tsx b/src/view/com/auth/login/ChooseAccountForm.tsx index add99789..c4a3b158 100644 --- a/src/view/com/auth/login/ChooseAccountForm.tsx +++ b/src/view/com/auth/login/ChooseAccountForm.tsx @@ -22,15 +22,12 @@ function AccountItem({ }) { const pal = usePalette('default') const {_} = useLingui() - const {isError, data} = useProfileQuery({did: account.did}) + const {data: profile} = useProfileQuery({did: account.did}) const onPress = React.useCallback(() => { onSelect(account) }, [account, onSelect]) - // TODO - if (isError) return null - return ( - + - {data?.displayName || account.handle}{' '} + {profile?.displayName || account.handle}{' '} {account.handle} diff --git a/src/view/com/modals/SwitchAccount.tsx b/src/view/com/modals/SwitchAccount.tsx index 55ba6936..05d0da37 100644 --- a/src/view/com/modals/SwitchAccount.tsx +++ b/src/view/com/modals/SwitchAccount.tsx @@ -29,7 +29,7 @@ function SwitchAccountCard({account}: {account: SessionAccount}) { const {track} = useAnalytics() const {isSwitchingAccounts, currentAccount} = useSession() const {logout} = useSessionApi() - const {isError, data: profile} = useProfileQuery({did: account.did}) + const {data: profile} = useProfileQuery({did: account.did}) const isCurrentAccount = account.did === currentAccount?.did const {onPressSwitchAccount} = useAccountSwitcher() @@ -38,9 +38,6 @@ function SwitchAccountCard({account}: {account: SessionAccount}) { logout() }, [track, logout]) - // TODO - if (isError || !currentAccount) return null - const contents = ( @@ -48,10 +45,10 @@ function SwitchAccountCard({account}: {account: SessionAccount}) { - {profile?.displayName || currentAccount.handle} + {profile?.displayName || currentAccount?.handle} - {currentAccount.handle} + {currentAccount?.handle} diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index cff92f8f..e2cd4c9e 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -72,21 +72,18 @@ function SettingsAccountCard({account}: {account: SessionAccount}) { const pal = usePalette('default') const {isSwitchingAccounts, currentAccount} = useSession() const {logout} = useSessionApi() - const {isError, data} = useProfileQuery({did: account.did}) + const {data: profile} = useProfileQuery({did: account.did}) const isCurrentAccount = account.did === currentAccount?.did const {onPressSwitchAccount} = useAccountSwitcher() - // TODO - if (isError || !currentAccount) return null - const contents = ( - + - {data?.displayName || account.handle} + {profile?.displayName || account.handle} {account.handle} @@ -99,7 +96,7 @@ function SettingsAccountCard({account}: {account: SessionAccount}) { onPress={logout} accessibilityRole="button" accessibilityLabel="Sign out" - accessibilityHint={`Signs ${data?.displayName} out of Bluesky`}> + accessibilityHint={`Signs ${profile?.displayName} out of Bluesky`}> Sign out diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index 45be67d2..0586323b 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -46,21 +46,15 @@ import {useSession} from '#/state/session' const ProfileCard = observer(function ProfileCardImpl() { const {currentAccount} = useSession() - const { - isLoading, - isError, - data: profile, - } = useProfileQuery({did: currentAccount!.did}) + const {isLoading, data: profile} = useProfileQuery({did: currentAccount!.did}) const {isDesktop} = useWebMediaQueries() const size = 48 - if (isError || !profile || !currentAccount) return null - - return !isLoading ? ( + return !isLoading && profile ? (