From 3d304dab1500ad8bab0dd86756393d0e4fc85147 Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 5 Oct 2025 08:20:38 +0100 Subject: [PATCH] fix: use bookmark pubkey for article author instead of tag lookup - Pass pubkey along with bookmark data to handleSelectUrl - Use bookmark.pubkey directly when constructing naddr - More reliable article loading with correct author attribution - Update type signatures across all components --- dist/index.html | 2 +- src/components/BookmarkItem.tsx | 4 ++-- src/components/BookmarkList.tsx | 2 +- src/components/BookmarkViews/CardView.tsx | 2 +- src/components/BookmarkViews/CompactView.tsx | 6 +++--- src/components/BookmarkViews/LargeView.tsx | 2 +- src/components/Bookmarks.tsx | 12 ++++-------- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/dist/index.html b/dist/index.html index 9e91ca23..ca1d04c8 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ Boris - Nostr Bookmarks - + diff --git a/src/components/BookmarkItem.tsx b/src/components/BookmarkItem.tsx index 1f74590b..28d46640 100644 --- a/src/components/BookmarkItem.tsx +++ b/src/components/BookmarkItem.tsx @@ -15,7 +15,7 @@ import { CardView } from './BookmarkViews/CardView' interface BookmarkItemProps { bookmark: IndividualBookmark index: number - onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][] }) => void + onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void viewMode?: ViewMode } @@ -73,7 +73,7 @@ export const BookmarkItem: React.FC = ({ bookmark, index, onS // For kind:30023 articles, pass the bookmark data instead of URL if (bookmark.kind === 30023) { if (onSelectUrl) { - onSelectUrl('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags }) + onSelectUrl('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags, pubkey: bookmark.pubkey }) } return } diff --git a/src/components/BookmarkList.tsx b/src/components/BookmarkList.tsx index 5d87c924..68805fa6 100644 --- a/src/components/BookmarkList.tsx +++ b/src/components/BookmarkList.tsx @@ -9,7 +9,7 @@ import { ViewMode } from './Bookmarks' interface BookmarkListProps { bookmarks: Bookmark[] - onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][] }) => void + onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void isCollapsed: boolean onToggleCollapse: () => void onLogout: () => void diff --git a/src/components/BookmarkViews/CardView.tsx b/src/components/BookmarkViews/CardView.tsx index b9620b1f..72344426 100644 --- a/src/components/BookmarkViews/CardView.tsx +++ b/src/components/BookmarkViews/CardView.tsx @@ -13,7 +13,7 @@ interface CardViewProps { index: number hasUrls: boolean extractedUrls: string[] - onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][] }) => void + onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void getIconForUrlType: IconGetter firstUrlClassification: { buttonText: string } | null authorNpub: string diff --git a/src/components/BookmarkViews/CompactView.tsx b/src/components/BookmarkViews/CompactView.tsx index e763e309..760054b5 100644 --- a/src/components/BookmarkViews/CompactView.tsx +++ b/src/components/BookmarkViews/CompactView.tsx @@ -11,7 +11,7 @@ interface CompactViewProps { index: number hasUrls: boolean extractedUrls: string[] - onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][] }) => void + onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void getIconForUrlType: IconGetter firstUrlClassification: { buttonText: string } | null } @@ -32,7 +32,7 @@ export const CompactView: React.FC = ({ if (!onSelectUrl) return if (isArticle) { - onSelectUrl('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags }) + onSelectUrl('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags, pubkey: bookmark.pubkey }) } else if (hasUrls) { onSelectUrl(extractedUrls[0]) } @@ -68,7 +68,7 @@ export const CompactView: React.FC = ({ onClick={(e) => { e.stopPropagation() if (isArticle) { - onSelectUrl?.('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags }) + onSelectUrl?.('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags, pubkey: bookmark.pubkey }) } else { onSelectUrl?.(extractedUrls[0]) } diff --git a/src/components/BookmarkViews/LargeView.tsx b/src/components/BookmarkViews/LargeView.tsx index a189f6b0..ea33c49f 100644 --- a/src/components/BookmarkViews/LargeView.tsx +++ b/src/components/BookmarkViews/LargeView.tsx @@ -10,7 +10,7 @@ interface LargeViewProps { index: number hasUrls: boolean extractedUrls: string[] - onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][] }) => void + onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void getIconForUrlType: IconGetter firstUrlClassification: { buttonText: string } | null previewImage: string | null diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index 63a244de..f51bccdc 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -114,7 +114,7 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { } } - const handleSelectUrl = async (url: string, bookmark?: { id: string; kind: number; tags: string[][] }) => { + const handleSelectUrl = async (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => { if (!relayPool) return setSelectedUrl(url) @@ -129,15 +129,11 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { // For articles, construct an naddr and fetch using article service const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1] || '' - // Try to get author from tags first, then fall back to bookmark id as pubkey - const author = bookmark.tags.find(t => t[0] === 'author')?.[1] || - (bookmark.id.length === 64 ? bookmark.id : undefined) - - if (dTag !== undefined) { + if (dTag !== undefined && bookmark.pubkey) { const pointer = { identifier: dTag, kind: 30023, - pubkey: author || bookmark.id, + pubkey: bookmark.pubkey, } const naddr = nip19.naddrEncode(pointer) const article = await fetchArticleByNaddr(relayPool, naddr) @@ -147,7 +143,7 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { url: `nostr:${naddr}` }) } else { - throw new Error('Invalid article reference - missing d tag') + throw new Error('Invalid article reference - missing d tag or pubkey') } } else { // For regular URLs, fetch readable content