mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 23:24:22 +01:00
fix: prevent duplicate highlights and remove excessive logging
- Add deduplication when adding highlights via onHighlightCreated - Remove excessive UI logging that was causing performance issues - Fixes duplicate highlight warning and improves render performance
This commit is contained in:
@@ -229,7 +229,14 @@ const Bookmarks: React.FC<BookmarksProps> = ({
|
||||
currentArticle,
|
||||
selectedUrl,
|
||||
readerContent,
|
||||
onHighlightCreated: (highlight) => setHighlights(prev => [highlight, ...prev]),
|
||||
onHighlightCreated: (highlight) => setHighlights(prev => {
|
||||
// Deduplicate by checking if highlight with this ID already exists
|
||||
const exists = prev.some(h => h.id === highlight.id)
|
||||
if (exists) {
|
||||
return prev // Don't add duplicate
|
||||
}
|
||||
return [highlight, ...prev]
|
||||
}),
|
||||
settings
|
||||
})
|
||||
|
||||
|
||||
@@ -310,39 +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
|
||||
})
|
||||
}
|
||||
|
||||
// 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(/\/$/, '')
|
||||
)
|
||||
const iconInfo = {
|
||||
return {
|
||||
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: isLocalOnly,
|
||||
iconType: isLocalOnly ? 'airplane' : 'highlighter',
|
||||
tooltip: iconInfo.tooltip,
|
||||
actualPublishedRelaysInUI: publishedRelays,
|
||||
relayNames: relayNames,
|
||||
conditionResult: isLocalOnly ? 'SHOULD_SHOW_AIRPLANE' : 'SHOULD_SHOW_HIGHLIGHTER'
|
||||
})
|
||||
|
||||
return iconInfo
|
||||
}
|
||||
|
||||
if (highlight.seenOnRelays && highlight.seenOnRelays.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user