From 4be8eff80a263fe76bbcb17c4e76b7145ad43d5a Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 2 Oct 2025 10:02:50 +0200 Subject: [PATCH] feat: add debugging for private bookmark decryption - Added detailed logging to understand why getHiddenBookmarks returns undefined - Check bookmark list content and encryption format - Verify account has decryption capabilities - Pass full account object with extension capabilities to applesauce helpers - This will help diagnose the NIP-44 vs NIP-04 encryption issue --- src/components/Bookmarks.tsx | 5 ++++- src/services/bookmarkService.ts | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index d84e873d..ce6c186b 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -16,6 +16,7 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { const [bookmarks, setBookmarks] = useState([]) const [loading, setLoading] = useState(true) const activeAccount = Hooks.useActiveAccount() + const accountManager = Hooks.useAccountManager() // Use ProfileModel to get user profile information const profile = useEventModel(Models.ProfileModel, activeAccount ? [activeAccount.pubkey] : null) @@ -45,7 +46,9 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { setLoading(false) }, 15000) // 15 second timeout - await fetchBookmarks(relayPool, activeAccount, setBookmarks, setLoading, timeoutId) + // Get the full account object with extension capabilities + const fullAccount = accountManager.getActive() + await fetchBookmarks(relayPool, fullAccount || activeAccount, setBookmarks, setLoading, timeoutId) } diff --git a/src/services/bookmarkService.ts b/src/services/bookmarkService.ts index 068870ca..8cf3fb39 100644 --- a/src/services/bookmarkService.ts +++ b/src/services/bookmarkService.ts @@ -20,6 +20,12 @@ interface ApplesauceBookmarks { urls?: BookmarkData[] } +interface AccountWithExtension { + pubkey: string + [key: string]: unknown // Allow other properties from the full account object +} + + const processBookmarks = ( bookmarks: unknown, activeAccount: ActiveAccount, @@ -75,9 +81,10 @@ const processApplesauceBookmarks = ( return processBookmarks(bookmarks, activeAccount, isPrivate) } + export const fetchBookmarks = async ( relayPool: RelayPool, - activeAccount: ActiveAccount, + activeAccount: AccountWithExtension, // Full account object with extension capabilities setBookmarks: (bookmarks: Bookmark[]) => void, setLoading: (loading: boolean) => void, timeoutId: number @@ -114,6 +121,14 @@ export const fetchBookmarks = async ( console.log('Public bookmarks:', publicBookmarks) console.log('Private bookmarks:', privateBookmarks) + // Debug the bookmark list event content + console.log('Bookmark list content:', bookmarkListEvent.content) + console.log('Bookmark list content type:', typeof bookmarkListEvent.content) + console.log('Has encrypted content:', bookmarkListEvent.content && bookmarkListEvent.content.includes(':')) + console.log('Account type:', typeof activeAccount) + console.log('Account has decrypt method:', typeof activeAccount.decrypt) + + // Process bookmarks using DRY helper function // Handle the structure that applesauce returns: {notes: [], articles: [], hashtags: [], urls: []} const publicItems = processApplesauceBookmarks(publicBookmarks, activeAccount, false)