import { toRelaySettings } from '@/lib/link' import { simplifyUrl } from '@/lib/url' import { SecondaryPageLink } from '@/PageManager' import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' import { useFeed } from '@/providers/FeedProvider' import { useNostr } from '@/providers/NostrProvider' import { BookmarkIcon, UsersRound, Server } from 'lucide-react' import { useTranslation } from 'react-i18next' import RelayIcon from '../RelayIcon' import RelaySetCard from '../RelaySetCard' export default function FeedSwitcher({ close }: { close?: () => void }) { const { t } = useTranslation() const { pubkey } = useNostr() const { relaySets, favoriteRelays, blockedRelays } = useFavoriteRelays() const { feedInfo, switchFeed } = useFeed() // Filter out blocked relays for display const visibleRelays = favoriteRelays.filter(relay => !blockedRelays.includes(relay)) return (
{pubkey && ( { if (!pubkey) return switchFeed('following', { pubkey }) close?.() }} >
{t('Following')}
)} {pubkey && ( { if (!pubkey) return switchFeed('bookmarks', { pubkey }) close?.() }} >
{t('Bookmarks')}
)} {visibleRelays.length > 0 && ( { console.log('FeedSwitcher: Switching to all-favorites') switchFeed('all-favorites') close?.() }} >
{t('All favorite relays')}
)}
close?.()} > {t('edit')}
{relaySets .filter((set) => set.relayUrls.length > 0) .map((set) => ( { if (!select) return switchFeed('relays', { activeRelaySetId: set.id }) close?.() }} /> ))} {visibleRelays.map((relay) => ( { switchFeed('relay', { relay }) close?.() }} >
{simplifyUrl(relay)}
))}
) } function FeedSwitcherItem({ children, isActive, onClick, controls }: { children: React.ReactNode isActive: boolean onClick: () => void controls?: React.ReactNode }) { return (
{children}
{controls}
) }