import { useQuery } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; import { VList } from 'virtua'; import { LoaderIcon, PlusIcon, ShareIcon } from '@shared/icons'; import { User } from '@shared/user'; import { useNostr } from '@utils/hooks/useNostr'; import { useRelay } from '@utils/hooks/useRelay'; export function RelayList() { const navigate = useNavigate(); const { getAllRelaysByUsers } = useNostr(); const { connectRelay } = useRelay(); const { status, data } = useQuery({ queryKey: ['relays'], queryFn: async () => { return await getAllRelaysByUsers(); }, refetchOnWindowFocus: false, refetchOnMount: false, refetchOnReconnect: false, staleTime: Infinity, }); const inspectRelay = (relayUrl: string) => { const url = new URL(relayUrl); navigate(`/relays/${url.hostname}`); }; return (
{status === 'pending' ? (

Loading relay...

) : (

Relay discovery

{[...data].map(([key, value]) => (
Relay:{' '} {key}
{value.slice(0, 4).map((item) => ( ))} {value.length > 4 ? (
+{value.length}
) : null}
))}
)}
); }