index.tsx raw

   1  import { Pubkey } from '@/domain'
   2  import { useFollowList } from '@/providers/FollowListProvider'
   3  import { UserRoundCheck } from 'lucide-react'
   4  import { useMemo } from 'react'
   5  import { useTranslation } from 'react-i18next'
   6  
   7  export default function FollowingBadge({ pubkey, userId }: { pubkey?: string; userId?: string }) {
   8    const { t } = useTranslation()
   9    const { followingSet } = useFollowList()
  10    const isFollowing = useMemo(() => {
  11      if (pubkey) return followingSet.has(pubkey)
  12  
  13      return userId ? followingSet.has(Pubkey.tryFromString(userId)?.hex ?? userId) : false
  14    }, [followingSet, pubkey, userId])
  15  
  16    if (!isFollowing) return null
  17  
  18    return (
  19      <div className="rounded-full bg-muted px-2 py-0.5 flex items-center" title={t('Following')}>
  20        <UserRoundCheck className="!size-3" />
  21      </div>
  22    )
  23  }
  24