From 00978e2e6469ef0597147c8e0bc9a280b8f225c5 Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 9 Oct 2025 21:08:00 +0100 Subject: [PATCH] chore: commit pending RelayStatusIndicator changes before URL update --- src/components/RelayStatusIndicator.tsx | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/components/RelayStatusIndicator.tsx b/src/components/RelayStatusIndicator.tsx index 51932a6c..c14df77a 100644 --- a/src/components/RelayStatusIndicator.tsx +++ b/src/components/RelayStatusIndicator.tsx @@ -13,7 +13,6 @@ export const RelayStatusIndicator: React.FC = ({ rela // Poll frequently for responsive offline indicator (5s instead of default 20s) const relayStatuses = useRelayStatus({ relayPool, pollingInterval: 5000 }) const [isConnecting, setIsConnecting] = useState(true) - const [connectingStartTime] = useState(Date.now()) if (!relayPool) return null @@ -27,27 +26,20 @@ export const RelayStatusIndicator: React.FC = ({ rela const localOnlyMode = hasLocalRelay && !hasRemoteRelay const offlineMode = connectedUrls.length === 0 - // Show "Connecting" for minimum duration (15s) to avoid flashing states + // Show "Connecting" for first few seconds or until relays connect useEffect(() => { - const MIN_CONNECTING_DURATION = 15000 // 15 seconds minimum - const elapsedTime = Date.now() - connectingStartTime - - if (connectedUrls.length > 0 && elapsedTime >= MIN_CONNECTING_DURATION) { - // Connected and minimum time passed - stop showing connecting state + if (connectedUrls.length > 0) { + // Connected! Stop showing connecting state setIsConnecting(false) - } else if (connectedUrls.length > 0) { - // Connected but haven't shown connecting long enough - const remainingTime = MIN_CONNECTING_DURATION - elapsedTime + } else { + // No connections yet - show connecting for 8 seconds + setIsConnecting(true) const timeout = setTimeout(() => { setIsConnecting(false) - }, remainingTime) + }, 8000) return () => clearTimeout(timeout) - } else if (elapsedTime >= MIN_CONNECTING_DURATION) { - // No connections and minimum time passed - show offline - setIsConnecting(false) } - // If no connections and time hasn't passed, keep showing connecting - }, [connectedUrls.length, connectingStartTime]) + }, [connectedUrls.length]) // Debug logging useEffect(() => {