fix: store event in EventStore after updating properties

- Move eventStore.add() call to AFTER updating __highlightProps with final values
- This ensures highlights loaded from EventStore have correct isLocalOnly and publishedRelays
- Reduce UI logging spam by only logging when values are meaningful
- This should fix the airplane icon not showing and reduce excessive re-renders
This commit is contained in:
Gigi
2025-10-30 20:56:50 +01:00
parent 78c58693a5
commit 959ccac857
2 changed files with 17 additions and 12 deletions

View File

@@ -310,14 +310,16 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
const isLocalOnly = highlight.isLocalOnly
const publishedRelays = highlight.publishedRelays || []
// Only log when values are meaningful (not undefined/empty) to reduce spam
if (isLocalOnly !== undefined || publishedRelays.length > 0) {
console.log('🎯 [HIGHLIGHT-UI] Rendering highlight relay indicator:', {
highlightId: highlight.id,
isLocalOnly: isLocalOnly,
publishedRelays: publishedRelays,
publishedRelayCount: publishedRelays.length,
willShowAirplaneIcon: isLocalOnly,
highlightObject: highlight // Log the entire highlight object to see what's actually there
willShowAirplaneIcon: isLocalOnly
})
}
// Show highlighter icon with relay info if available
if (highlight.publishedRelays && highlight.publishedRelays.length > 0) {

View File

@@ -117,16 +117,13 @@ export async function createHighlight(
// Sign the event
const signedEvent = await factory.sign(highlightEvent)
// Attach custom properties to the event for later retrieval
// Initialize custom properties on the event (will be updated after publishing)
;(signedEvent as any).__highlightProps = {
publishedRelays: [],
isLocalOnly: false,
isSyncing: false
}
// Store the event in EventStore first for immediate UI display
eventStore.add(signedEvent)
// Publish to all relays and get individual responses
const allRelays = RELAYS
let publishResponses: { ok: boolean; message?: string; from: string }[] = []
@@ -184,6 +181,9 @@ export async function createHighlight(
isSyncing: false
}
// Store the event in EventStore AFTER updating with final properties
eventStore.add(signedEvent)
// Mark for offline sync if we're in local-only mode
if (isLocalOnly) {
console.log('✈️ [HIGHLIGHT-PUBLISH] Marking event for offline sync (flight mode)')
@@ -205,6 +205,9 @@ export async function createHighlight(
isSyncing: false
}
// Store the event in EventStore AFTER updating with final properties
eventStore.add(signedEvent)
console.log('✈️ [HIGHLIGHT-PUBLISH] Publishing failed, marking for offline sync (flight mode)')
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
markEventAsOfflineCreated(signedEvent.id)