Remove error states, just best effort
parent
60386f8f07
commit
499021229a
|
@ -22,15 +22,12 @@ function AccountItem({
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {isError, data} = useProfileQuery({did: account.did})
|
const {data: profile} = useProfileQuery({did: account.did})
|
||||||
|
|
||||||
const onPress = React.useCallback(() => {
|
const onPress = React.useCallback(() => {
|
||||||
onSelect(account)
|
onSelect(account)
|
||||||
}, [account, onSelect])
|
}, [account, onSelect])
|
||||||
|
|
||||||
// TODO
|
|
||||||
if (isError) return null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
testID={`chooseAccountBtn-${account.handle}`}
|
testID={`chooseAccountBtn-${account.handle}`}
|
||||||
|
@ -42,11 +39,11 @@ function AccountItem({
|
||||||
accessibilityHint="Double tap to sign in">
|
accessibilityHint="Double tap to sign in">
|
||||||
<View style={[pal.borderDark, styles.groupContent, styles.noTopBorder]}>
|
<View style={[pal.borderDark, styles.groupContent, styles.noTopBorder]}>
|
||||||
<View style={s.p10}>
|
<View style={s.p10}>
|
||||||
<UserAvatar avatar={data?.avatar} size={30} />
|
<UserAvatar avatar={profile?.avatar} size={30} />
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.accountText}>
|
<Text style={styles.accountText}>
|
||||||
<Text type="lg-bold" style={pal.text}>
|
<Text type="lg-bold" style={pal.text}>
|
||||||
{data?.displayName || account.handle}{' '}
|
{profile?.displayName || account.handle}{' '}
|
||||||
</Text>
|
</Text>
|
||||||
<Text type="lg" style={[pal.textLight]}>
|
<Text type="lg" style={[pal.textLight]}>
|
||||||
{account.handle}
|
{account.handle}
|
||||||
|
|
|
@ -29,7 +29,7 @@ function SwitchAccountCard({account}: {account: SessionAccount}) {
|
||||||
const {track} = useAnalytics()
|
const {track} = useAnalytics()
|
||||||
const {isSwitchingAccounts, currentAccount} = useSession()
|
const {isSwitchingAccounts, currentAccount} = useSession()
|
||||||
const {logout} = useSessionApi()
|
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 isCurrentAccount = account.did === currentAccount?.did
|
||||||
const {onPressSwitchAccount} = useAccountSwitcher()
|
const {onPressSwitchAccount} = useAccountSwitcher()
|
||||||
|
|
||||||
|
@ -38,9 +38,6 @@ function SwitchAccountCard({account}: {account: SessionAccount}) {
|
||||||
logout()
|
logout()
|
||||||
}, [track, logout])
|
}, [track, logout])
|
||||||
|
|
||||||
// TODO
|
|
||||||
if (isError || !currentAccount) return null
|
|
||||||
|
|
||||||
const contents = (
|
const contents = (
|
||||||
<View style={[pal.view, styles.linkCard]}>
|
<View style={[pal.view, styles.linkCard]}>
|
||||||
<View style={styles.avi}>
|
<View style={styles.avi}>
|
||||||
|
@ -48,10 +45,10 @@ function SwitchAccountCard({account}: {account: SessionAccount}) {
|
||||||
</View>
|
</View>
|
||||||
<View style={[s.flex1]}>
|
<View style={[s.flex1]}>
|
||||||
<Text type="md-bold" style={pal.text} numberOfLines={1}>
|
<Text type="md-bold" style={pal.text} numberOfLines={1}>
|
||||||
{profile?.displayName || currentAccount.handle}
|
{profile?.displayName || currentAccount?.handle}
|
||||||
</Text>
|
</Text>
|
||||||
<Text type="sm" style={pal.textLight} numberOfLines={1}>
|
<Text type="sm" style={pal.textLight} numberOfLines={1}>
|
||||||
{currentAccount.handle}
|
{currentAccount?.handle}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|
|
@ -72,21 +72,18 @@ function SettingsAccountCard({account}: {account: SessionAccount}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {isSwitchingAccounts, currentAccount} = useSession()
|
const {isSwitchingAccounts, currentAccount} = useSession()
|
||||||
const {logout} = useSessionApi()
|
const {logout} = useSessionApi()
|
||||||
const {isError, data} = useProfileQuery({did: account.did})
|
const {data: profile} = useProfileQuery({did: account.did})
|
||||||
const isCurrentAccount = account.did === currentAccount?.did
|
const isCurrentAccount = account.did === currentAccount?.did
|
||||||
const {onPressSwitchAccount} = useAccountSwitcher()
|
const {onPressSwitchAccount} = useAccountSwitcher()
|
||||||
|
|
||||||
// TODO
|
|
||||||
if (isError || !currentAccount) return null
|
|
||||||
|
|
||||||
const contents = (
|
const contents = (
|
||||||
<View style={[pal.view, styles.linkCard]}>
|
<View style={[pal.view, styles.linkCard]}>
|
||||||
<View style={styles.avi}>
|
<View style={styles.avi}>
|
||||||
<UserAvatar size={40} avatar={data?.avatar} />
|
<UserAvatar size={40} avatar={profile?.avatar} />
|
||||||
</View>
|
</View>
|
||||||
<View style={[s.flex1]}>
|
<View style={[s.flex1]}>
|
||||||
<Text type="md-bold" style={pal.text}>
|
<Text type="md-bold" style={pal.text}>
|
||||||
{data?.displayName || account.handle}
|
{profile?.displayName || account.handle}
|
||||||
</Text>
|
</Text>
|
||||||
<Text type="sm" style={pal.textLight}>
|
<Text type="sm" style={pal.textLight}>
|
||||||
{account.handle}
|
{account.handle}
|
||||||
|
@ -99,7 +96,7 @@ function SettingsAccountCard({account}: {account: SessionAccount}) {
|
||||||
onPress={logout}
|
onPress={logout}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel="Sign out"
|
accessibilityLabel="Sign out"
|
||||||
accessibilityHint={`Signs ${data?.displayName} out of Bluesky`}>
|
accessibilityHint={`Signs ${profile?.displayName} out of Bluesky`}>
|
||||||
<Text type="lg" style={pal.link}>
|
<Text type="lg" style={pal.link}>
|
||||||
Sign out
|
Sign out
|
||||||
</Text>
|
</Text>
|
||||||
|
|
|
@ -46,21 +46,15 @@ import {useSession} from '#/state/session'
|
||||||
|
|
||||||
const ProfileCard = observer(function ProfileCardImpl() {
|
const ProfileCard = observer(function ProfileCardImpl() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {
|
const {isLoading, data: profile} = useProfileQuery({did: currentAccount!.did})
|
||||||
isLoading,
|
|
||||||
isError,
|
|
||||||
data: profile,
|
|
||||||
} = useProfileQuery({did: currentAccount!.did})
|
|
||||||
const {isDesktop} = useWebMediaQueries()
|
const {isDesktop} = useWebMediaQueries()
|
||||||
const size = 48
|
const size = 48
|
||||||
|
|
||||||
if (isError || !profile || !currentAccount) return null
|
return !isLoading && profile ? (
|
||||||
|
|
||||||
return !isLoading ? (
|
|
||||||
<Link
|
<Link
|
||||||
href={makeProfileLink({
|
href={makeProfileLink({
|
||||||
did: currentAccount.did,
|
did: currentAccount!.did,
|
||||||
handle: currentAccount.handle,
|
handle: currentAccount!.handle,
|
||||||
})}
|
})}
|
||||||
style={[styles.profileCard, !isDesktop && styles.profileCardTablet]}
|
style={[styles.profileCard, !isDesktop && styles.profileCardTablet]}
|
||||||
title="My Profile"
|
title="My Profile"
|
||||||
|
|
Loading…
Reference in New Issue