|
|
|
@ -9,32 +9,31 @@ import { useMemo } from 'react' |
|
|
|
import BottomNavigationBarItem from './BottomNavigationBarItem' |
|
|
|
import BottomNavigationBarItem from './BottomNavigationBarItem' |
|
|
|
|
|
|
|
|
|
|
|
export default function AccountButton() { |
|
|
|
export default function AccountButton() { |
|
|
|
const { navigate, current } = usePrimaryPage() |
|
|
|
const { navigate, current, display } = usePrimaryPage() |
|
|
|
const { pubkey, profile } = useNostr() |
|
|
|
const { pubkey, profile } = useNostr() |
|
|
|
const defaultAvatar = useMemo( |
|
|
|
const defaultAvatar = useMemo( |
|
|
|
() => (profile?.pubkey ? generateImageByPubkey(profile.pubkey) : ''), |
|
|
|
() => (profile?.pubkey ? generateImageByPubkey(profile.pubkey) : ''), |
|
|
|
[profile] |
|
|
|
[profile] |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
const active = useMemo(() => current === 'me' && display, [display, current]) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<BottomNavigationBarItem |
|
|
|
<BottomNavigationBarItem |
|
|
|
onClick={() => { |
|
|
|
onClick={() => { |
|
|
|
navigate('me') |
|
|
|
navigate('me') |
|
|
|
}} |
|
|
|
}} |
|
|
|
active={current === 'me'} |
|
|
|
active={active} |
|
|
|
> |
|
|
|
> |
|
|
|
{pubkey ? ( |
|
|
|
{pubkey ? ( |
|
|
|
profile ? ( |
|
|
|
profile ? ( |
|
|
|
<Avatar className={cn('w-7 h-7', current === 'me' ? 'ring-primary ring-1' : '')}> |
|
|
|
<Avatar className={cn('w-7 h-7', active ? 'ring-primary ring-1' : '')}> |
|
|
|
<AvatarImage src={profile.avatar} className="object-cover object-center" /> |
|
|
|
<AvatarImage src={profile.avatar} className="object-cover object-center" /> |
|
|
|
<AvatarFallback> |
|
|
|
<AvatarFallback> |
|
|
|
<img src={defaultAvatar} /> |
|
|
|
<img src={defaultAvatar} /> |
|
|
|
</AvatarFallback> |
|
|
|
</AvatarFallback> |
|
|
|
</Avatar> |
|
|
|
</Avatar> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<Skeleton |
|
|
|
<Skeleton className={cn('w-7 h-7 rounded-full', active ? 'ring-primary ring-1' : '')} /> |
|
|
|
className={cn('w-7 h-7 rounded-full', current === 'me' ? 'ring-primary ring-1' : '')} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<UserRound /> |
|
|
|
<UserRound /> |
|
|
|
|