import UserAvatar from '@/components/UserAvatar' import { Button } from '@/components/ui/button' import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from '@/components/ui/sheet' import { getProfileFromEvent } from '@/lib/event-metadata' import { cn } from '@/lib/utils' import { toProfile } from '@/lib/link' import { collectAggregatedNip05sFromKind0, truncateAbout } from '@/lib/relay-pulse-nip05' import { useMuteList } from '@/contexts/mute-list-context' import { useFavoriteRelaysActivity } from '@/providers/favorite-relays-activity-context' import { SecondaryPageLink } from '@/PageManager' import type { Event } from 'nostr-tools' import { Users } from 'lucide-react' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' const ABOUT_PREVIEW_LEN = 250 function CompactProfileCard({ event }: { event: Event }) { const profile = getProfileFromEvent(event) const nip05s = collectAggregatedNip05sFromKind0(event) const about = truncateAbout(profile.about, ABOUT_PREVIEW_LEN) return (
{profile.username} {about ? (

{about}

) : null} {nip05s.length > 0 ? (
    {nip05s.map((id) => (
  • {id}
  • ))}
) : null}
) } export function RelayPulseActiveNpubsOpenButton({ className, size = 'sm', variant = 'outline' }: { className?: string size?: 'sm' | 'icon' variant?: 'outline' | 'ghost' }) { const { t } = useTranslation() const { setActiveNpubsDrawerOpen, totalCount } = useFavoriteRelaysActivity() if (totalCount === 0) return null const countLabel = ( {totalCount > 99 ? '99+' : totalCount} ) return ( ) } /** Mounted once inside {@link FavoriteRelaysActivityProvider}. */ export function RelayPulseActiveNpubsSheet() { const { t } = useTranslation() const { mutePubkeySet } = useMuteList() const { activeNpubsDrawerOpen, setActiveNpubsDrawerOpen, followPubkeys, otherPubkeys, profileKind0ByPubkey, profilesLoading } = useFavoriteRelaysActivity() const followWithProfile = useMemo( () => followPubkeys.filter( (pk) => profileKind0ByPubkey[pk] && !mutePubkeySet.has(pk) ), [followPubkeys, profileKind0ByPubkey, mutePubkeySet] ) const othersWithProfile = useMemo( () => otherPubkeys.filter( (pk) => profileKind0ByPubkey[pk] && !mutePubkeySet.has(pk) ), [otherPubkeys, profileKind0ByPubkey, mutePubkeySet] ) return ( {t('Relay pulse active npubs')} {t('Relay pulse active npubs hint')}
{profilesLoading ? (

{t('Loading...')}

) : null}
{followWithProfile.length > 0 ? (

{t('Relay pulse drawer following')}

{followWithProfile.map((pk) => { const ev = profileKind0ByPubkey[pk] return ev ? : null })}
) : null} {othersWithProfile.length > 0 ? (

{t('Relay pulse drawer others')}

{othersWithProfile.map((pk) => { const ev = profileKind0ByPubkey[pk] return ev ? : null })}
) : null} {!profilesLoading && followWithProfile.length === 0 && othersWithProfile.length === 0 ? (

{t('Relay pulse drawer no profiles')}

) : null}
) }