From d2c1a16ca63b02d5d2b3fcbc91072b213ebf7c9d Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 22 Oct 2025 00:17:03 +0200 Subject: [PATCH] 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 --- src/services/bookmarkController.ts | 51 ------------------------------ src/services/bookmarkHelpers.ts | 2 -- 2 files changed, 53 deletions(-) diff --git a/src/services/bookmarkController.ts b/src/services/bookmarkController.ts index e0c66222..9606783d 100644 --- a/src/services/bookmarkController.ts +++ b/src/services/bookmarkController.ts @@ -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) => { // 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])) } diff --git a/src/services/bookmarkHelpers.ts b/src/services/bookmarkHelpers.ts index c72f5fcd..10b1b2de 100644 --- a/src/services/bookmarkHelpers.ts +++ b/src/services/bookmarkHelpers.ts @@ -170,11 +170,9 @@ export function hydrateItems( items: IndividualBookmark[], idToEvent: Map ): 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))