chore: remove verbose debug logging from hydration

- Clean up console output after diagnosing ID mismatch issue
- Keep error logging for when matches aren't found
- Deduplication before hydration now working
This commit is contained in:
Gigi
2025-10-22 00:17:03 +02:00
parent b8242312b5
commit d2c1a16ca6
2 changed files with 0 additions and 53 deletions

View File

@@ -136,8 +136,6 @@ class BookmarkController {
return
}
console.log(`📡 hydrateByIds: requesting ${unique.length} events from EventLoader`)
// Convert IDs to EventPointers
const pointers: EventPointer[] = unique.map(id => ({ id }))
@@ -152,22 +150,6 @@ class BookmarkController {
idToEvent.set(event.id, event)
// Log all fetched events to see what we're getting
console.log('📥 Fetched event:', {
id: event.id.slice(0, 12),
kind: event.kind,
contentLen: event.content?.length || 0,
totalInMap: idToEvent.size
})
if (event.kind === 1 && event.content) {
console.log('✅ Fetched kind:1 with content:', {
id: event.id.slice(0, 12),
content: event.content.slice(0, 30),
totalInMap: idToEvent.size
})
}
// Also index by coordinate for addressable events
if (event.kind && event.kind >= 30000 && event.kind < 40000) {
const dTag = event.tags?.find((t: string[]) => t[0] === 'd')?.[1] || ''
@@ -286,10 +268,6 @@ class BookmarkController {
console.log(`📋 Requesting hydration for: ${noteIds.length} note IDs, ${coordinates.length} coordinates`)
// Show sample of what we're requesting
const sampleIds = noteIds.slice(0, 3)
console.log(`📋 Sample note IDs to request:`, sampleIds)
// Helper to build and emit bookmarks
const emitBookmarks = (idToEvent: Map<string, NostrEvent>) => {
// Now hydrate the ORIGINAL items (which may have duplicates), using the deduplicated results
@@ -299,21 +277,6 @@ class BookmarkController {
...hydrateItems(privateItemsAll, idToEvent)
]
// Debug: log what we have
const kind1Items = allBookmarks.filter(b => b.kind === 1)
if (kind1Items.length > 0) {
console.log('🔄 Emitting bookmarks with hydration:', {
totalKind1: kind1Items.length,
withContent: kind1Items.filter(b => b.content).length,
mapSize: idToEvent.size,
sample: kind1Items.slice(0, 2).map(b => ({
id: b.id.slice(0, 12),
content: b.content?.slice(0, 30),
inMap: idToEvent.has(b.id)
}))
})
}
const enriched = allBookmarks.map(b => ({
...b,
tags: b.tags || [],
@@ -338,20 +301,6 @@ class BookmarkController {
encryptedContent: undefined
}
// Debug: log the actual content being emitted
const kind1InEmit = sortedBookmarks.filter(b => b.kind === 1)
if (kind1InEmit.length > 0) {
console.log('📤 Emitting Bookmark object with individualBookmarks:', {
totalKind1: kind1InEmit.length,
withContent: kind1InEmit.filter(b => b.content && b.content.length > 0).length,
samples: kind1InEmit.slice(0, 2).map(b => ({
id: b.id.slice(0, 12),
content: b.content?.slice(0, 20),
contentLength: b.content?.length
}))
})
}
this.bookmarksListeners.forEach(cb => cb([bookmark]))
}

View File

@@ -170,11 +170,9 @@ export function hydrateItems(
items: IndividualBookmark[],
idToEvent: Map<string, NostrEvent>
): IndividualBookmark[] {
// Debug: log what we're trying to hydrate
const kind1Items = items.filter(b => b.kind === 1)
if (kind1Items.length > 0 && idToEvent.size > 0) {
const found = kind1Items.filter(b => idToEvent.has(b.id))
console.log(`💧 hydrateItems: ${found.length}/${kind1Items.length} kind:1 items found in map (map has ${idToEvent.size} total events)`)
if (found.length === 0 && kind1Items.length > 0) {
console.log('❌ NO MATCHES! Sample item IDs:', kind1Items.slice(0, 3).map(b => b.id))
console.log('❌ Map keys:', Array.from(idToEvent.keys()).slice(0, 3))