diff --git a/app/layout.tsx b/app/layout.tsx index 42ab822..4da65f3 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -30,10 +30,10 @@ export default function RootLayout({ const customRelays = JSON.parse(localStorage.getItem("customRelays") || "[]"); if (customRelays.length > 0) { // Remove trailing slashes from any relay URLs - const sanitizedRelays = customRelays.map((relay: string) => + const sanitizedRelays = customRelays.map((relay: string) => relay.endsWith('/') ? relay.slice(0, -1) : relay ); - + setRelayUrls(prevRelays => { // Combine default relays with custom relays, removing duplicates const allRelays = [...prevRelays, ...sanitizedRelays]; @@ -61,11 +61,11 @@ export default function RootLayout({ disableTransitionOnChange themes={["light", "dark", "purple-light", "purple-dark", "vintage-light", "vintage-dark", "neo-brutalism-light", "neo-brutalism-dark", "nature-light", "nature-dark", "system"]} > - -
+ + {children}
diff --git a/app/relays/page.tsx b/app/relays/page.tsx index 3e0f440..5f2c23b 100644 --- a/app/relays/page.tsx +++ b/app/relays/page.tsx @@ -25,6 +25,13 @@ export default function RelaysPage() { useEffect(() => { document.title = `Relays | LUMINA`; + // Set a loading timeout - if relays don't connect within 10 seconds, show whatever we have + const loadingTimeout = setTimeout(() => { + if (loading) { + setLoading(false); + } + }, 10000); + if (connectedRelays) { const status: { [url: string]: 'connected' | 'connecting' | 'disconnected' | 'error' } = {}; @@ -40,8 +47,14 @@ export default function RelaysPage() { }); setRelayStatus(status); - setLoading(false); + + // Only stop loading when we have at least one connected relay or after a timeout + if (Object.values(status).some(s => s === 'connected') || connectedRelays.length === 0) { + setLoading(false); + } } + + return () => clearTimeout(loadingTimeout); }, [connectedRelays, refreshKey]); // Function to refresh NIP-65 relays for the current user @@ -141,7 +154,7 @@ export default function RelaysPage() { return (
-

Nostr Relays

+

Relays

diff --git a/components/headerComponents/AuthButton.tsx b/components/headerComponents/AuthButton.tsx new file mode 100644 index 0000000..0589dd9 --- /dev/null +++ b/components/headerComponents/AuthButton.tsx @@ -0,0 +1,37 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import Link from "next/link"; +import { UserIcon } from "lucide-react"; + +export default function AuthButton() { + return ( + + + + + + + + Sign In + + + + + Register + + + + + ); +} diff --git a/components/headerComponents/ConnectedRelaysButton.tsx b/components/headerComponents/ConnectedRelaysButton.tsx new file mode 100644 index 0000000..eff3043 --- /dev/null +++ b/components/headerComponents/ConnectedRelaysButton.tsx @@ -0,0 +1,43 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import React, { useEffect, useState } from 'react'; +import Link from "next/link"; +import { useNostr } from "nostr-react"; +import { Wifi } from "lucide-react"; + +export default function ConnectedRelaysButton() { + const { connectedRelays } = useNostr(); + const [relayCount, setRelayCount] = useState(0); + const [isConnecting, setIsConnecting] = useState(true); + + useEffect(() => { + // Update relay count when connectedRelays changes + if (connectedRelays && connectedRelays.length > 0) { + // Count only connected relays (status === 1) + const activeRelays = connectedRelays.filter(relay => relay.status === 1).length; + setRelayCount(activeRelays); + + // If at least one relay is connected, we're no longer in connecting state + if (activeRelays > 0) { + setIsConnecting(false); + } + } + + // Set a timeout to stop showing "Connecting..." after a reasonable time + const timer = setTimeout(() => { + setIsConnecting(false); + }, 5000); + + return () => clearTimeout(timer); + }, [connectedRelays]); + + return ( + + + + ); +} \ No newline at end of file diff --git a/components/headerComponents/TopNavigation.tsx b/components/headerComponents/TopNavigation.tsx index 74d2c9f..f3a70bc 100644 --- a/components/headerComponents/TopNavigation.tsx +++ b/components/headerComponents/TopNavigation.tsx @@ -4,10 +4,11 @@ import { siteConfig } from "@/config/site" import { useEffect, useState } from "react" import { TopNavigationItems } from "./TopNavigationItems" import { DropdownThemeMode } from "./DropdownThemeMode" -import LoginButton from "./LoginButton" import { AvatarDropdown } from "./AvatarDropdown" -import RegisterButton from "./RegisterButton" -import GitHubButton from "@/components/headerComponents/GitHubButton" +import ConnectedRelaysButton from "@/components/headerComponents/ConnectedRelaysButton" +import AuthButton from "./AuthButton" +import { Button } from "@/components/ui/button" +import { UserIcon } from "lucide-react" export function TopNavigation() { const [pubkey, setPubkey] = useState(null) @@ -26,8 +27,13 @@ export function TopNavigation() {
@@ -41,11 +47,9 @@ export function TopNavigation() {