From af7eb48893835d2fab8cd3fcb57c4deb109292f2 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 31 Oct 2025 00:01:09 +0100 Subject: [PATCH] fix: add fallback logic for detecting flight mode highlights - Add isEventOfflineCreated function to check offline sync service - Use offline sync service as fallback if isLocalOnly is undefined - Also check if publishedRelays only contains local relays - This provides multiple fallback mechanisms to detect flight mode highlights - Should finally fix the airplane icon not showing --- src/components/HighlightItem.tsx | 30 +++++++++++++++++++++++------- src/services/offlineSyncService.ts | 7 +++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/components/HighlightItem.tsx b/src/components/HighlightItem.tsx index ef905295..cf557a11 100644 --- a/src/components/HighlightItem.tsx +++ b/src/components/HighlightItem.tsx @@ -307,18 +307,34 @@ export const HighlightItem: React.FC = ({ } // Check if this highlight was only published to local relays - const isLocalOnly = highlight.isLocalOnly + let isLocalOnly = highlight.isLocalOnly const publishedRelays = highlight.publishedRelays || [] - // Debug: Log what we're working with (remove after fixing) - if (highlight.id && (isLocalOnly !== undefined || publishedRelays.length > 0)) { - console.log('🔍 [HIGHLIGHT-UI-DEBUG] Highlight data:', { + // Fallback 1: Check if this highlight was marked for offline sync (flight mode) + if (isLocalOnly === undefined) { + const { isEventOfflineCreated } = require('../services/offlineSyncService') + if (isEventOfflineCreated(highlight.id)) { + isLocalOnly = true + } + } + + // Fallback 2: If publishedRelays only contains local relays, it's local-only + if (isLocalOnly === undefined && publishedRelays.length > 0) { + const { isLocalRelay } = require('../utils/helpers') + const hasOnlyLocalRelays = publishedRelays.every(url => isLocalRelay(url)) + const hasRemoteRelays = publishedRelays.some(url => !isLocalRelay(url)) + if (hasOnlyLocalRelays && !hasRemoteRelays) { + isLocalOnly = true + } + } + + // Debug: Log for flight mode highlights + if (highlight.id && (isLocalOnly === true || publishedRelays.some(url => url.includes('localhost')))) { + console.log('🔍 [HIGHLIGHT-UI-DEBUG] Flight mode highlight:', { highlightId: highlight.id, isLocalOnly, publishedRelays, - seenOnRelays: highlight.seenOnRelays, - willUsePublishedRelays: !!(highlight.publishedRelays && highlight.publishedRelays.length > 0), - willUseSeenOnRelays: !!(highlight.seenOnRelays && highlight.seenOnRelays.length > 0) + willShowAirplane: isLocalOnly === true }) } diff --git a/src/services/offlineSyncService.ts b/src/services/offlineSyncService.ts index 73e49a0f..901ea936 100644 --- a/src/services/offlineSyncService.ts +++ b/src/services/offlineSyncService.ts @@ -22,6 +22,13 @@ export function markEventAsOfflineCreated(eventId: string): void { offlineCreatedEvents.add(eventId) } +/** + * Check if an event was created during offline period (flight mode) + */ +export function isEventOfflineCreated(eventId: string): boolean { + return offlineCreatedEvents.has(eventId) +} + /** * Check if an event is currently being synced */