import Relay from '@/components/Relay' import RelayIcon from '@/components/RelayIcon' import PrimaryPageLayout from '@/layouts/PrimaryPageLayout' import { normalizeUrl, simplifyUrl } from '@/lib/url' import { usePrimaryPage } from '@/PageManager' import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' import { useRelayAdmin } from '@/providers/RelayAdminProvider' import { TPageRef } from '@/types' import { Server, Shield } from 'lucide-react' import { forwardRef, lazy, Suspense, useMemo } from 'react' const RelayAdminPanel = lazy(() => import('./admin')) const RelayPage = forwardRef(({ url }: { url?: string }, ref) => { const normalizedUrl = useMemo(() => (url ? normalizeUrl(url) : undefined), [url]) const { isEmbedded, isAdmin, isLoading } = useRelayAdmin() const showAdmin = isEmbedded && isAdmin && !normalizedUrl return ( } displayScrollToTopButton ref={ref} > {normalizedUrl ? ( ) : showAdmin ? ( Loading admin... } > ) : isEmbedded && !isLoading ? (
Log in as admin to access relay management.
) : ( )}
) }) RelayPage.displayName = 'RelayPage' export default RelayPage function RelayList() { const { favoriteRelays } = useFavoriteRelays() const { navigate } = usePrimaryPage() if (favoriteRelays.length === 0) { return (
No relays configured.
) } return (
{favoriteRelays.map((relay) => ( ))}
) } function RelayPageTitlebar({ url, showAdmin }: { url?: string; showAdmin?: boolean }) { return (
{showAdmin ? : }
{showAdmin ? 'Relay Admin' : url ? simplifyUrl(url) : 'Relays'}
) }