import { NDKKind, NDKSubscriptionCacheUsage } from '@nostr-dev-kit/ndk'; import { useQuery } from '@tanstack/react-query'; import { RelayForm } from '@app/relays/components/relayForm'; import { useNDK } from '@libs/ndk/provider'; import { useStorage } from '@libs/storage/provider'; import { CancelIcon } from '@shared/icons'; import { useRelay } from '@utils/hooks/useRelay'; export function UserRelayList() { const { db } = useStorage(); const { ndk } = useNDK(); const { removeRelay } = useRelay(); const { status, data } = useQuery({ queryKey: ['relays', db.account.pubkey], queryFn: async () => { const event = await ndk.fetchEvent( { kinds: [NDKKind.RelayList], authors: [db.account.pubkey], }, { cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY } ); if (!event) throw new Error('relay set not found'); return event.tags; }, refetchOnWindowFocus: false, }); const currentRelays = new Set([...ndk.pool.relays.values()].map((item) => item.url)); return (
Loading...
) : !data ? (You not have personal relay set yet
{item[1]}