From 4fa01231cd27cd68d1bf615f342150f0b598d9bb Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 30 Oct 2025 20:35:51 +0100 Subject: [PATCH] fix: determine isLocalOnly before publishing, not after - Move connection status check before publishEvent call - Set isLocalOnly based on actual connection state at creation time - This ensures airplane icon shows correctly in flight mode - Previous logic was checking after publishing, which was too late --- src/services/highlightCreationService.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/services/highlightCreationService.ts b/src/services/highlightCreationService.ts index 49054a46..2087f39c 100644 --- a/src/services/highlightCreationService.ts +++ b/src/services/highlightCreationService.ts @@ -118,10 +118,7 @@ export async function createHighlight( // Sign the event const signedEvent = await factory.sign(highlightEvent) - // Use unified write service to store and publish - await publishEvent(relayPool, eventStore, signedEvent) - - // Check current connection status for UI feedback + // Check current connection status BEFORE publishing const connectedRelays = Array.from(relayPool.relays.values()) .filter(relay => relay.connected) .map(relay => relay.url) @@ -129,10 +126,10 @@ export async function createHighlight( const hasRemoteConnection = connectedRelays.some(url => !isLocalRelay(url)) const hasLocalConnection = connectedRelays.some(url => isLocalRelay(url)) - // Determine which relays we actually published to - const expectedSuccessRelays = hasRemoteConnection - ? RELAYS // Published to all relays (local + remote) - : RELAYS.filter(isLocalRelay) // Only published to local relays + // Determine which relays we should publish to + const targetRelays = hasRemoteConnection + ? RELAYS // Publish to all relays (local + remote) + : RELAYS.filter(isLocalRelay) // Only publish to local relays // isLocalOnly is true if we only have local connections (flight mode) const isLocalOnly = hasLocalConnection && !hasRemoteConnection @@ -141,13 +138,16 @@ export async function createHighlight( connectedRelays, hasRemoteConnection, hasLocalConnection, - expectedSuccessRelays, + targetRelays, isLocalOnly }) + // Use unified write service to store and publish + await publishEvent(relayPool, eventStore, signedEvent) + // Convert to Highlight with relay tracking info and return IMMEDIATELY const highlight = eventToHighlight(signedEvent) - highlight.publishedRelays = expectedSuccessRelays + highlight.publishedRelays = targetRelays highlight.isLocalOnly = isLocalOnly return highlight