mirror of
https://github.com/dergigi/boris.git
synced 2025-12-20 16:14:20 +01:00
debug: add comprehensive logging for flight mode detection
- Add detailed logs with [HIGHLIGHT-PUBLISH] prefix for publication process - Add detailed logs with [HIGHLIGHT-UI] prefix for UI rendering - Log relay responses, success/failure analysis, and flight mode reasoning - Log icon decision making process in UI component - This will help debug why airplane icon isn't showing in flight mode
This commit is contained in:
@@ -309,16 +309,32 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
||||
// Check if this highlight was only published to local relays
|
||||
const isLocalOnly = highlight.isLocalOnly
|
||||
|
||||
console.log('🎯 [HIGHLIGHT-UI] Rendering highlight relay indicator:', {
|
||||
highlightId: highlight.id,
|
||||
isLocalOnly,
|
||||
publishedRelays: highlight.publishedRelays,
|
||||
willShowAirplaneIcon: isLocalOnly
|
||||
})
|
||||
|
||||
// Show highlighter icon with relay info if available
|
||||
if (highlight.publishedRelays && highlight.publishedRelays.length > 0) {
|
||||
const relayNames = highlight.publishedRelays.map(url =>
|
||||
url.replace(/^wss?:\/\//, '').replace(/\/$/, '')
|
||||
)
|
||||
return {
|
||||
const iconInfo = {
|
||||
icon: isLocalOnly ? faPlane : faHighlighter,
|
||||
tooltip: isLocalOnly ? 'Local relays only - will sync when remote relays available' : relayNames.join('\n'),
|
||||
spin: false
|
||||
}
|
||||
|
||||
console.log('🔍 [HIGHLIGHT-UI] Icon decision made:', {
|
||||
highlightId: highlight.id,
|
||||
isLocalOnly,
|
||||
iconType: isLocalOnly ? 'airplane' : 'highlighter',
|
||||
tooltip: iconInfo.tooltip
|
||||
})
|
||||
|
||||
return iconInfo
|
||||
}
|
||||
|
||||
if (highlight.seenOnRelays && highlight.seenOnRelays.length > 0) {
|
||||
|
||||
@@ -125,40 +125,63 @@ export async function createHighlight(
|
||||
let publishResponses: { ok: boolean; message?: string; from: string }[] = []
|
||||
let isLocalOnly = false
|
||||
|
||||
console.log('🚀 [HIGHLIGHT-PUBLISH] Starting highlight publication process', {
|
||||
eventId: signedEvent.id,
|
||||
allRelays,
|
||||
relayCount: allRelays.length
|
||||
})
|
||||
|
||||
try {
|
||||
// Publish to all relays and wait for responses
|
||||
console.log('📡 [HIGHLIGHT-PUBLISH] Publishing to all relays...')
|
||||
publishResponses = await relayPool.publish(allRelays, signedEvent)
|
||||
|
||||
console.log('📨 [HIGHLIGHT-PUBLISH] Received responses from relays:', publishResponses)
|
||||
|
||||
// Determine which relays successfully accepted the event
|
||||
const successfulRelays = publishResponses
|
||||
.filter(response => response.ok)
|
||||
.map(response => response.from)
|
||||
|
||||
const failedRelays = publishResponses
|
||||
.filter(response => !response.ok)
|
||||
.map(response => ({ from: response.from, message: response.message }))
|
||||
|
||||
const successfulLocalRelays = successfulRelays.filter(url => isLocalRelay(url))
|
||||
const successfulRemoteRelays = successfulRelays.filter(url => !isLocalRelay(url))
|
||||
|
||||
// isLocalOnly is true if only local relays accepted the event
|
||||
isLocalOnly = successfulLocalRelays.length > 0 && successfulRemoteRelays.length === 0
|
||||
|
||||
console.log('🔍 Highlight creation debug:', {
|
||||
allRelays,
|
||||
publishResponses,
|
||||
successfulRelays,
|
||||
console.log('✅ [HIGHLIGHT-PUBLISH] Publishing analysis:', {
|
||||
totalRelays: allRelays.length,
|
||||
successfulRelays: successfulRelays.length,
|
||||
failedRelays: failedRelays.length,
|
||||
successfulLocalRelays,
|
||||
successfulRemoteRelays,
|
||||
isLocalOnly
|
||||
failedRelays,
|
||||
isLocalOnly,
|
||||
flightModeReason: isLocalOnly
|
||||
? 'Only local relays accepted the event'
|
||||
: successfulRemoteRelays.length > 0
|
||||
? 'Remote relays also accepted the event'
|
||||
: 'No relays accepted the event'
|
||||
})
|
||||
|
||||
// Mark for offline sync if we're in local-only mode
|
||||
if (isLocalOnly) {
|
||||
console.log('✈️ [HIGHLIGHT-PUBLISH] Marking event for offline sync (flight mode)')
|
||||
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
|
||||
markEventAsOfflineCreated(signedEvent.id)
|
||||
} else {
|
||||
console.log('🌐 [HIGHLIGHT-PUBLISH] Event published to remote relays, no offline sync needed')
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.warn('⚠️ Failed to publish highlight to relays:', error)
|
||||
console.error('❌ [HIGHLIGHT-PUBLISH] Failed to publish highlight to relays:', error)
|
||||
// If publishing fails completely, assume local-only mode
|
||||
isLocalOnly = true
|
||||
console.log('✈️ [HIGHLIGHT-PUBLISH] Publishing failed, marking for offline sync (flight mode)')
|
||||
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
|
||||
markEventAsOfflineCreated(signedEvent.id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user