import { buildExplorePopularRelayUrls } from '@/lib/explore-popular-relays' import { toRelay } from '@/lib/link' import { normalizeAnyRelayUrl, simplifyUrl } from '@/lib/url' import { useSmartRelayNavigation } from '@/PageManager' import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' import { useNostr } from '@/providers/NostrProvider' import indexedDb from '@/services/indexed-db.service' import { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' /** * Lightweight Explore relay list: URLs from the viewer's NIP-65 / favorites / defaults and optional * cached NIP-66 data — no GitHub collections fetch and no NIP-11 storm on mount. */ export default function ExplorePopularRelays() { const { t } = useTranslation() const { relayList } = useNostr() const { favoriteRelays, blockedRelays } = useFavoriteRelays() const { navigateToRelay } = useSmartRelayNavigation() const [nip66Cached, setNip66Cached] = useState([]) useEffect(() => { let cancelled = false void indexedDb .getPublicLivelyRelayUrlsCache() .then((c) => { if (!cancelled && c?.urls?.length) setNip66Cached(c.urls) }) .catch(() => {}) return () => { cancelled = true } }, []) const urls = useMemo( () => buildExplorePopularRelayUrls({ relayList, favoriteRelays, blockedRelays, nip66CachedUrls: nip66Cached }), [relayList, favoriteRelays, blockedRelays, nip66Cached] ) if (urls.length === 0) { return (

{t('No relays in your lists yet.')}

) } return (

{t('Popular relays')}

{t('From your mailbox, favorites, and cached relay lists on this device.')}

) }