fix: 🐛

This commit is contained in:
codytseng 2025-10-25 14:54:37 +08:00
parent 402bc91566
commit 92041b73f1
3 changed files with 58 additions and 18 deletions

View file

@ -1,20 +1,15 @@
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Skeleton } from '@/components/ui/skeleton'
import { generateImageByPubkey } from '@/lib/pubkey'
import { cn } from '@/lib/utils'
import { usePrimaryPage } from '@/PageManager'
import { useNostr } from '@/providers/NostrProvider'
import { UserRound } from 'lucide-react'
import { useMemo } from 'react'
import { SimpleUserAvatar } from '../UserAvatar'
import BottomNavigationBarItem from './BottomNavigationBarItem'
export default function AccountButton() {
const { navigate, current, display } = usePrimaryPage()
const { pubkey, profile } = useNostr()
const defaultAvatar = useMemo(
() => (profile?.pubkey ? generateImageByPubkey(profile.pubkey) : ''),
[profile]
)
const active = useMemo(() => current === 'me' && display, [display, current])
return (
@ -26,12 +21,10 @@ export default function AccountButton() {
>
{pubkey ? (
profile ? (
<Avatar className={cn('w-7 h-7', active ? 'ring-primary ring-1' : '')}>
<AvatarImage src={profile.avatar} className="object-cover object-center" />
<AvatarFallback>
<img src={defaultAvatar} />
</AvatarFallback>
</Avatar>
<SimpleUserAvatar
userId={pubkey}
className={cn('w-7 h-7', active ? 'ring-primary ring-1' : '')}
/>
) : (
<Skeleton className={cn('w-7 h-7 rounded-full', active ? 'ring-primary ring-1' : '')} />
)