import { useSecondaryPage } from '@/PageManager' import { Badge } from '@/components/ui/badge' import { useFetchRelayInfo, useFetchRelayList } from '@/hooks' import { toRelay } from '@/lib/link' import { userIdToPubkey } from '@/lib/pubkey' import { TMailboxRelay } from '@/types' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import RelaySimpleInfo from '../RelaySimpleInfo' export default function OthersRelayList({ userId }: { userId: string }) { const { t } = useTranslation() const pubkey = useMemo(() => userIdToPubkey(userId), [userId]) const { relayList, isFetching } = useFetchRelayList(pubkey) if (isFetching) { return
{t('loading...')}
} return (
{relayList.originalRelays.map((relay, index) => ( ))}
) } function RelayItem({ relay }: { relay: TMailboxRelay }) { const { t } = useTranslation() const { push } = useSecondaryPage() const { relayInfo } = useFetchRelayInfo(relay.url) const { url, scope } = relay return (
push(toRelay(url))}>
{['both', 'read'].includes(scope) && ( {t('Read')} )} {['both', 'write'].includes(scope) && ( {t('Write')} )}
) }