diff --git a/src/components/FeedRelaysIconRow/index.tsx b/src/components/FeedRelaysIconRow/index.tsx new file mode 100644 index 00000000..db29cdc8 --- /dev/null +++ b/src/components/FeedRelaysIconRow/index.tsx @@ -0,0 +1,33 @@ +import RelayIcon from '@/components/RelayIcon' +import { simplifyUrl } from '@/lib/url' +import { cn } from '@/lib/utils' +import { useTranslation } from 'react-i18next' + +export function FeedRelaysIconRow({ + urls, + className +}: { + urls: readonly string[] + className?: string +}) { + const { t } = useTranslation() + if (urls.length === 0) return null + + return ( +
+ {urls.map((url) => ( + + + + ))} +
+ ) +} diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index a60c4088..a1c2658e 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -1,5 +1,6 @@ import NewNotesButton from '@/components/NewNotesButton' import { AlexandriaEventsSearchEmptyCta } from '@/components/AlexandriaEventsSearchEmptyCta' +import { FeedRelaysIconRow } from '@/components/FeedRelaysIconRow' import { ExtendedKind, FAST_READ_RELAY_URLS, @@ -27,6 +28,7 @@ import { } from '@/lib/spell-feed-request-identity' import logger from '@/lib/logger' import { eventSeenOnMatchesAllowlist } from '@/lib/relay-allowlist' +import { uniqueRelayUrlsFromSubRequests } from '@/lib/feed-relay-urls' import { isLocalNetworkUrl, normalizeAnyRelayUrl, normalizeUrl } from '@/lib/url' import { eventPassesNoteListKindPicker } from '@/lib/feed-kind-filter' import { collectLocalEventsForTextSearch } from '@/lib/local-nip50-search-merge' @@ -1013,16 +1015,10 @@ const NoteList = forwardRef( // Memoize subRequests serialization to avoid expensive JSON.stringify on every render const subRequestsKey = useMemo(() => legacyFeedSubscriptionKey(subRequests), [subRequests]) - const feedRelayUrls = useMemo(() => { - const urls = new Set() - for (const req of subRequests) { - for (const url of req.urls ?? []) { - const trimmed = url.trim() - if (trimmed) urls.add(trimmed) - } - } - return [...urls] - }, [subRequestsKey]) + const feedRelayUrls = useMemo( + () => uniqueRelayUrlsFromSubRequests(subRequests), + [subRequestsKey] + ) const feedAttestedSuperchatIds = useFeedAttestedSuperchatIds(feedRelayUrls) @@ -4519,6 +4515,12 @@ const NoteList = forwardRef( const feedClientFilterPanel = feedClientFilterOpen ? (
+ {feedRelayUrls.length > 0 ? ( +
+

{t('Feed relays', { defaultValue: 'Relays in this feed' })}

+ +
+ ) : null}