From aced38b1470be023a6bcb39fe45c964bc282a214 Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 9 Oct 2025 16:41:45 +0100 Subject: [PATCH] fix(highlights): only show successfully reachable relays in flight mode When creating highlights in flight mode (no remote connection), only show local relays in the relay indicator tooltip. Check connection status to determine which relays are actually reachable before setting publishedRelays field. --- src/services/highlightCreationService.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/services/highlightCreationService.ts b/src/services/highlightCreationService.ts index 6b5568a2..365e3ebd 100644 --- a/src/services/highlightCreationService.ts +++ b/src/services/highlightCreationService.ts @@ -114,12 +114,27 @@ export async function createHighlight( eventStore.add(signedEvent) console.log('💾 Stored highlight in EventStore:', signedEvent.id.slice(0, 8)) - // Check if we're only publishing to local relays - const isLocalOnly = areAllRelaysLocal(targetRelays) + // Check current connection status - are we online or in flight mode? + const connectedRelays = Array.from(relayPool.relays.values()) + .filter(relay => relay.connected) + .map(relay => relay.url) + + const hasRemoteConnection = connectedRelays.some(url => + !url.includes('localhost') && !url.includes('127.0.0.1') + ) + + // Determine which relays we expect to succeed + const expectedSuccessRelays = hasRemoteConnection + ? RELAYS + : RELAYS.filter(r => r.includes('localhost') || r.includes('127.0.0.1')) + + const isLocalOnly = areAllRelaysLocal(expectedSuccessRelays) console.log('📍 Highlight relay status:', { - targetRelays, + targetRelays: targetRelays.length, + expectedSuccessRelays, isLocalOnly, + hasRemoteConnection, eventId: signedEvent.id }) @@ -130,7 +145,7 @@ export async function createHighlight( // Convert to Highlight with relay tracking info and return IMMEDIATELY const highlight = eventToHighlight(signedEvent) - highlight.publishedRelays = targetRelays + highlight.publishedRelays = expectedSuccessRelays // Show only relays we expect to succeed highlight.isLocalOnly = isLocalOnly highlight.isOfflineCreated = isLocalOnly // Mark as created offline if local-only