mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 06:34:24 +01:00
perf: remove excessive debug logging for better performance
- Remove debug logs from highlight creation, publishing, and UI rendering - Keep only essential error logging - Improves performance by reducing console spam - Flight mode detection still works via fallback mechanisms
This commit is contained in:
@@ -321,17 +321,6 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,
|
|
||||||
highlightPublishedRelays: highlight.publishedRelays,
|
|
||||||
highlightIsLocalOnly: highlight.isLocalOnly,
|
|
||||||
willShowAirplane: isLocalOnly === true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// If isLocalOnly is true (from any fallback), show airplane icon
|
// If isLocalOnly is true (from any fallback), show airplane icon
|
||||||
if (isLocalOnly === true) {
|
if (isLocalOnly === true) {
|
||||||
|
|||||||
@@ -44,14 +44,6 @@ export const useHighlightCreation = ({
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleCreateHighlight = useCallback(async (text: string) => {
|
const handleCreateHighlight = useCallback(async (text: string) => {
|
||||||
console.log('🎯 [HIGHLIGHT-CREATION] Starting highlight creation process', {
|
|
||||||
text: text.substring(0, 50) + '...',
|
|
||||||
hasActiveAccount: !!activeAccount,
|
|
||||||
hasRelayPool: !!relayPool,
|
|
||||||
hasEventStore: !!eventStore,
|
|
||||||
hasCurrentArticle: !!currentArticle,
|
|
||||||
hasSelectedUrl: !!selectedUrl
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!activeAccount || !relayPool || !eventStore) {
|
if (!activeAccount || !relayPool || !eventStore) {
|
||||||
console.error('Missing requirements for highlight creation')
|
console.error('Missing requirements for highlight creation')
|
||||||
@@ -69,7 +61,6 @@ export const useHighlightCreation = ({
|
|||||||
? currentArticle.content
|
? currentArticle.content
|
||||||
: readerContent?.markdown || readerContent?.html
|
: readerContent?.markdown || readerContent?.html
|
||||||
|
|
||||||
console.log('🎯 [HIGHLIGHT-CREATION] Calling createHighlight function')
|
|
||||||
const newHighlight = await createHighlight(
|
const newHighlight = await createHighlight(
|
||||||
text,
|
text,
|
||||||
source,
|
source,
|
||||||
@@ -82,13 +73,6 @@ export const useHighlightCreation = ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Highlight created successfully
|
// Highlight created successfully
|
||||||
console.log('🎯 [HIGHLIGHT-CREATION] Highlight created successfully:', {
|
|
||||||
highlightId: newHighlight.id,
|
|
||||||
isLocalOnly: newHighlight.isLocalOnly,
|
|
||||||
publishedRelays: newHighlight.publishedRelays,
|
|
||||||
willShowAirplaneIcon: newHighlight.isLocalOnly
|
|
||||||
})
|
|
||||||
|
|
||||||
// Clear the browser's text selection immediately to allow DOM update
|
// Clear the browser's text selection immediately to allow DOM update
|
||||||
const selection = window.getSelection()
|
const selection = window.getSelection()
|
||||||
if (selection) {
|
if (selection) {
|
||||||
|
|||||||
@@ -142,24 +142,15 @@ export async function createHighlight(
|
|||||||
let publishResponses: { ok: boolean; message?: string; from: string }[] = []
|
let publishResponses: { ok: boolean; message?: string; from: string }[] = []
|
||||||
let isLocalOnly = false
|
let isLocalOnly = false
|
||||||
|
|
||||||
console.log('🚀 [HIGHLIGHT-PUBLISH] Starting highlight publication process', {
|
|
||||||
eventId: signedEvent.id,
|
|
||||||
connectedRelays,
|
|
||||||
connectedRelayCount: connectedRelays.length
|
|
||||||
})
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Publish only to connected relays to avoid long timeouts
|
// Publish only to connected relays to avoid long timeouts
|
||||||
if (connectedRelays.length === 0) {
|
if (connectedRelays.length === 0) {
|
||||||
console.log('⚠️ [HIGHLIGHT-PUBLISH] No connected relays, marking as local-only')
|
|
||||||
isLocalOnly = true
|
isLocalOnly = true
|
||||||
} else {
|
} else {
|
||||||
console.log('📡 [HIGHLIGHT-PUBLISH] Publishing to connected relays...')
|
|
||||||
publishResponses = await relayPool.publish(connectedRelays, signedEvent)
|
publishResponses = await relayPool.publish(connectedRelays, signedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('📨 [HIGHLIGHT-PUBLISH] Received responses from relays:', publishResponses)
|
|
||||||
|
|
||||||
// Determine which relays successfully accepted the event
|
// Determine which relays successfully accepted the event
|
||||||
const successfulRelays = publishResponses
|
const successfulRelays = publishResponses
|
||||||
.filter(response => response.ok)
|
.filter(response => response.ok)
|
||||||
@@ -175,20 +166,6 @@ export async function createHighlight(
|
|||||||
// isLocalOnly is true if only local relays accepted the event
|
// isLocalOnly is true if only local relays accepted the event
|
||||||
isLocalOnly = successfulLocalRelays.length > 0 && successfulRemoteRelays.length === 0
|
isLocalOnly = successfulLocalRelays.length > 0 && successfulRemoteRelays.length === 0
|
||||||
|
|
||||||
console.log('✅ [HIGHLIGHT-PUBLISH] Publishing analysis:', {
|
|
||||||
connectedRelays: connectedRelays.length,
|
|
||||||
successfulRelays: successfulRelays.length,
|
|
||||||
failedRelays: failedRelays.length,
|
|
||||||
failedRelayDetails: failedRelays,
|
|
||||||
successfulLocalRelays,
|
|
||||||
successfulRemoteRelays,
|
|
||||||
isLocalOnly,
|
|
||||||
flightModeReason: isLocalOnly
|
|
||||||
? 'Only local relays accepted the event'
|
|
||||||
: successfulRemoteRelays.length > 0
|
|
||||||
? 'Remote relays also accepted the event'
|
|
||||||
: 'No relays accepted the event'
|
|
||||||
})
|
|
||||||
|
|
||||||
// Handle case when no relays were connected
|
// Handle case when no relays were connected
|
||||||
const successfulRelaysList = publishResponses.length > 0
|
const successfulRelaysList = publishResponses.length > 0
|
||||||
@@ -216,11 +193,8 @@ export async function createHighlight(
|
|||||||
|
|
||||||
// Mark for offline sync if we're in local-only mode
|
// Mark for offline sync if we're in local-only mode
|
||||||
if (isLocalOnly) {
|
if (isLocalOnly) {
|
||||||
console.log('✈️ [HIGHLIGHT-PUBLISH] Marking event for offline sync (flight mode)')
|
|
||||||
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
|
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
|
||||||
markEventAsOfflineCreated(signedEvent.id)
|
markEventAsOfflineCreated(signedEvent.id)
|
||||||
} else {
|
|
||||||
console.log('🌐 [HIGHLIGHT-PUBLISH] Event published to remote relays, no offline sync needed')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -245,7 +219,6 @@ export async function createHighlight(
|
|||||||
// Store the event in EventStore AFTER updating with final properties
|
// Store the event in EventStore AFTER updating with final properties
|
||||||
eventStore.add(signedEvent)
|
eventStore.add(signedEvent)
|
||||||
|
|
||||||
console.log('✈️ [HIGHLIGHT-PUBLISH] Publishing failed, marking for offline sync (flight mode)')
|
|
||||||
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
|
const { markEventAsOfflineCreated } = await import('./offlineSyncService')
|
||||||
markEventAsOfflineCreated(signedEvent.id)
|
markEventAsOfflineCreated(signedEvent.id)
|
||||||
}
|
}
|
||||||
@@ -263,14 +236,6 @@ export async function createHighlight(
|
|||||||
highlight.publishedRelays = finalPublishedRelays
|
highlight.publishedRelays = finalPublishedRelays
|
||||||
highlight.isLocalOnly = isLocalOnly
|
highlight.isLocalOnly = isLocalOnly
|
||||||
highlight.isSyncing = false
|
highlight.isSyncing = false
|
||||||
|
|
||||||
console.log('🔄 [HIGHLIGHT-CREATION] Final highlight properties set:', {
|
|
||||||
eventId: signedEvent.id,
|
|
||||||
publishedRelays: highlight.publishedRelays,
|
|
||||||
isLocalOnly: highlight.isLocalOnly,
|
|
||||||
isSyncing: highlight.isSyncing,
|
|
||||||
relayCount: highlight.publishedRelays.length
|
|
||||||
})
|
|
||||||
|
|
||||||
return highlight
|
return highlight
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ export function setHighlightMetadata(
|
|||||||
}
|
}
|
||||||
): void {
|
): void {
|
||||||
highlightMetadataCache.set(eventId, metadata)
|
highlightMetadataCache.set(eventId, metadata)
|
||||||
console.log('💾 [HIGHLIGHT-METADATA] Stored metadata in cache:', {
|
|
||||||
eventId,
|
|
||||||
metadata
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,16 +78,6 @@ export function eventToHighlight(event: NostrEvent): Highlight {
|
|||||||
// Fall back to __highlightProps if cache doesn't have it (for backwards compatibility)
|
// Fall back to __highlightProps if cache doesn't have it (for backwards compatibility)
|
||||||
const customProps = cachedMetadata || (event as HighlightEvent).__highlightProps || {}
|
const customProps = cachedMetadata || (event as HighlightEvent).__highlightProps || {}
|
||||||
|
|
||||||
// Debug: Log cache lookup for recently created highlights
|
|
||||||
if (event.id && (cachedMetadata || (event as HighlightEvent).__highlightProps)) {
|
|
||||||
console.log('🔍 [EVENT-TO-HIGHLIGHT] Cache lookup:', {
|
|
||||||
eventId: event.id,
|
|
||||||
foundInCache: !!cachedMetadata,
|
|
||||||
hasHighlightProps: !!(event as HighlightEvent).__highlightProps,
|
|
||||||
customProps
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
pubkey: event.pubkey,
|
pubkey: event.pubkey,
|
||||||
|
|||||||
Reference in New Issue
Block a user