Live (#8354)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
useNavigationState,
|
||||
} from '@react-navigation/native'
|
||||
|
||||
import {useActorStatus} from '#/lib/actor-status'
|
||||
import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher'
|
||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||
import {usePalette} from '#/lib/hooks/usePalette'
|
||||
@@ -100,6 +101,8 @@ function ProfileCard() {
|
||||
profile: profiles?.find(p => p.did === account.did),
|
||||
}))
|
||||
|
||||
const {isActive: live} = useActorStatus(profile)
|
||||
|
||||
return (
|
||||
<View style={[a.my_md, !leftNavMinimal && [a.w_full, a.align_start]]}>
|
||||
{!isLoading && profile ? (
|
||||
@@ -142,6 +145,7 @@ function ProfileCard() {
|
||||
avatar={profile.avatar}
|
||||
size={size}
|
||||
type={profile?.associated?.labeler ? 'labeler' : 'user'}
|
||||
live={live}
|
||||
/>
|
||||
</View>
|
||||
{!leftNavMinimal && (
|
||||
@@ -226,7 +230,6 @@ function SwitchMenuItems({
|
||||
signOutPromptControl: DialogControlProps
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
const {onPressSwitchAccount, pendingDid} = useAccountSwitcher()
|
||||
const {setShowLoggedOut} = useLoggedOutViewControls()
|
||||
const closeEverything = useCloseAllActiveElements()
|
||||
|
||||
@@ -243,35 +246,11 @@ function SwitchMenuItems({
|
||||
<Trans>Switch account</Trans>
|
||||
</Menu.LabelText>
|
||||
{accounts.map(other => (
|
||||
<Menu.Item
|
||||
disabled={!!pendingDid}
|
||||
style={[{minWidth: 150}]}
|
||||
<SwitchMenuItem
|
||||
key={other.account.did}
|
||||
label={_(
|
||||
msg`Switch to ${sanitizeHandle(
|
||||
other.profile?.handle ?? other.account.handle,
|
||||
'@',
|
||||
)}`,
|
||||
)}
|
||||
onPress={() =>
|
||||
onPressSwitchAccount(other.account, 'SwitchAccount')
|
||||
}>
|
||||
<View style={[{marginLeft: tokens.space._2xs * -1}]}>
|
||||
<UserAvatar
|
||||
avatar={other.profile?.avatar}
|
||||
size={20}
|
||||
type={
|
||||
other.profile?.associated?.labeler ? 'labeler' : 'user'
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<Menu.ItemText>
|
||||
{sanitizeHandle(
|
||||
other.profile?.handle ?? other.account.handle,
|
||||
'@',
|
||||
)}
|
||||
</Menu.ItemText>
|
||||
</Menu.Item>
|
||||
account={other.account}
|
||||
profile={other.profile}
|
||||
/>
|
||||
))}
|
||||
</Menu.Group>
|
||||
<Menu.Divider />
|
||||
@@ -295,6 +274,45 @@ function SwitchMenuItems({
|
||||
)
|
||||
}
|
||||
|
||||
function SwitchMenuItem({
|
||||
account,
|
||||
profile,
|
||||
}: {
|
||||
account: SessionAccount
|
||||
profile: AppBskyActorDefs.ProfileViewDetailed | undefined
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
const {onPressSwitchAccount, pendingDid} = useAccountSwitcher()
|
||||
const {isActive: live} = useActorStatus(profile)
|
||||
|
||||
return (
|
||||
<Menu.Item
|
||||
disabled={!!pendingDid}
|
||||
style={[a.gap_sm, {minWidth: 150}]}
|
||||
key={account.did}
|
||||
label={_(
|
||||
msg`Switch to ${sanitizeHandle(
|
||||
profile?.handle ?? account.handle,
|
||||
'@',
|
||||
)}`,
|
||||
)}
|
||||
onPress={() => onPressSwitchAccount(account, 'SwitchAccount')}>
|
||||
<View>
|
||||
<UserAvatar
|
||||
avatar={profile?.avatar}
|
||||
size={20}
|
||||
type={profile?.associated?.labeler ? 'labeler' : 'user'}
|
||||
live={live}
|
||||
hideLiveBadge
|
||||
/>
|
||||
</View>
|
||||
<Menu.ItemText>
|
||||
{sanitizeHandle(profile?.handle ?? account.handle, '@')}
|
||||
</Menu.ItemText>
|
||||
</Menu.Item>
|
||||
)
|
||||
}
|
||||
|
||||
interface NavItemProps {
|
||||
count?: string
|
||||
hasNew?: boolean
|
||||
|
||||
Reference in New Issue
Block a user