import { useSecondaryPage } from '@/PageManager' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { useFetchRelayList } from '@/hooks/useFetchRelayList' import { toRelay } from '@/lib/link' import { userIdToPubkey } from '@/lib/pubkey' import { relayListToMailboxRelay } from '@/lib/relay' import { simplifyUrl } from '@/lib/url' import { TMailboxRelay } from '@/types' import { ListPlus, Telescope } from 'lucide-react' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import RelayIcon from '../RelayIcon' import SaveRelayDropdownMenu from '../SaveRelayDropdownMenu' export default function OthersRelayList({ userId }: { userId: string }) { const { t } = useTranslation() const pubkey = useMemo(() => userIdToPubkey(userId), [userId]) const { relayList, isFetching } = useFetchRelayList(pubkey) const mailboxRelays = useMemo(() => relayListToMailboxRelay(relayList), [relayList]) if (isFetching) { return
{t('loading...')}
} return (
{mailboxRelays.map((relay, index) => ( ))}
) } function RelayItem({ relay }: { relay: TMailboxRelay }) { const { t } = useTranslation() const { push } = useSecondaryPage() const { url, scope } = relay return (
push(toRelay(url))} >
{simplifyUrl(url)}
{scope === 'read' ? ( {t('Read')} ) : scope === 'write' ? ( {t('Write')} ) : null}
) }