diff --git a/src/components/HighlightItem.tsx b/src/components/HighlightItem.tsx index 736b4ab9..d30f34fe 100644 --- a/src/components/HighlightItem.tsx +++ b/src/components/HighlightItem.tsx @@ -140,8 +140,6 @@ export const HighlightItem: React.FC = ({ setIsSyncing(syncingState) // When sync completes successfully, update highlight to show all relays if (!syncingState) { - setShowOfflineIndicator(false) - // Update the highlight with all relays after successful sync if (onHighlightUpdate && highlight.isLocalOnly && relayPool) { const updatedHighlight = { @@ -285,9 +283,6 @@ export const HighlightItem: React.FC = ({ onHighlightUpdate(updatedHighlight) } - // Update local state - setShowOfflineIndicator(false) - } catch (error) { console.error('❌ Failed to rebroadcast:', error) } finally { diff --git a/src/hooks/useArticleLoader.ts b/src/hooks/useArticleLoader.ts index 823fe616..a90034bf 100644 --- a/src/hooks/useArticleLoader.ts +++ b/src/hooks/useArticleLoader.ts @@ -315,6 +315,9 @@ export function useArticleLoader({ return () => { mountedRef.current = false } + // Dependencies intentionally excluded to prevent re-renders when relay/eventStore state changes + // This fixes the loading skeleton appearing when going offline (flight mode) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ naddr, previewData diff --git a/src/hooks/useExternalUrlLoader.ts b/src/hooks/useExternalUrlLoader.ts index a61168fe..51bb6130 100644 --- a/src/hooks/useExternalUrlLoader.ts +++ b/src/hooks/useExternalUrlLoader.ts @@ -165,6 +165,9 @@ export function useExternalUrlLoader({ return () => { mountedRef.current = false } + // Dependencies intentionally excluded to prevent re-renders when relay/eventStore state changes + // This fixes the loading skeleton appearing when going offline (flight mode) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ url, cachedUrlHighlights diff --git a/src/services/highlightCreationService.ts b/src/services/highlightCreationService.ts index 3bc60646..eb2b6590 100644 --- a/src/services/highlightCreationService.ts +++ b/src/services/highlightCreationService.ts @@ -7,13 +7,22 @@ import { Helpers, IEventStore } from 'applesauce-core' import { RELAYS } from '../config/relays' import { Highlight } from '../types/highlights' import { UserSettings } from './settingsService' -import { isLocalRelay, areAllRelaysLocal } from '../utils/helpers' +import { isLocalRelay } from '../utils/helpers' import { setHighlightMetadata } from './highlightEventProcessor' // Boris pubkey for zap splits // npub19802see0gnk3vjlus0dnmfdagusqrtmsxpl5yfmkwn9uvnfnqylqduhr0x export const BORIS_PUBKEY = '29dea8672f44ed164bfc83db3da5bd472001af70307f42277674cbc64d33013e' +// Extended event type with highlight metadata +interface HighlightEvent extends NostrEvent { + __highlightProps?: { + publishedRelays?: string[] + isLocalOnly?: boolean + isSyncing?: boolean + } +} + const { getHighlightText, getHighlightContext, @@ -119,7 +128,7 @@ export async function createHighlight( const signedEvent = await factory.sign(highlightEvent) // Initialize custom properties on the event (will be updated after publishing) - ;(signedEvent as any).__highlightProps = { + ;(signedEvent as HighlightEvent).__highlightProps = { publishedRelays: [], isLocalOnly: false, isSyncing: false @@ -170,9 +179,9 @@ export async function createHighlight( connectedRelays: connectedRelays.length, successfulRelays: successfulRelays.length, failedRelays: failedRelays.length, + failedRelayDetails: failedRelays, successfulLocalRelays, successfulRemoteRelays, - failedRelays, isLocalOnly, flightModeReason: isLocalOnly ? 'Only local relays accepted the event' @@ -196,7 +205,7 @@ export async function createHighlight( }) // Also update the event with the actual properties (for backwards compatibility) - ;(signedEvent as any).__highlightProps = { + ;(signedEvent as HighlightEvent).__highlightProps = { publishedRelays: successfulRelaysList, isLocalOnly, isSyncing: false @@ -227,7 +236,7 @@ export async function createHighlight( }) // Also update the event with the error state (for backwards compatibility) - ;(signedEvent as any).__highlightProps = { + ;(signedEvent as HighlightEvent).__highlightProps = { publishedRelays: [], isLocalOnly: true, isSyncing: false diff --git a/src/services/highlightEventProcessor.ts b/src/services/highlightEventProcessor.ts index 736f100d..7e99b203 100644 --- a/src/services/highlightEventProcessor.ts +++ b/src/services/highlightEventProcessor.ts @@ -2,6 +2,15 @@ import { NostrEvent } from 'nostr-tools' import { Helpers } from 'applesauce-core' import { Highlight } from '../types/highlights' +// Extended event type with highlight metadata +interface HighlightEvent extends NostrEvent { + __highlightProps?: { + publishedRelays?: string[] + isLocalOnly?: boolean + isSyncing?: boolean + } +} + const { getHighlightText, getHighlightContext, @@ -67,7 +76,7 @@ export function eventToHighlight(event: NostrEvent): Highlight { const cachedMetadata = getHighlightMetadata(event.id) // Fall back to __highlightProps if cache doesn't have it (for backwards compatibility) - const customProps = cachedMetadata || (event as any).__highlightProps || {} + const customProps = cachedMetadata || (event as HighlightEvent).__highlightProps || {} return { id: event.id,