Fix article bookmarks using note-style e tag instead of a tag

ArticleView was using addBookmark(eventId) which saves an e tag,
putting articles in the Notes tab. Now uses addArticleBookmark
with the 30023:pubkey:d-tag address so articles appear correctly
under the Articles tab in bookmarks.
This commit is contained in:
Jure
2026-03-30 08:19:18 +02:00
parent 5e8e548c42
commit 6ed0b50d33

View File

@@ -79,7 +79,7 @@ export function ArticleView() {
const [showComment, setShowComment] = useState(false);
const [commentText, setCommentText] = useState("");
const autoResize = useAutoResize(3, 10);
const { isBookmarked, addBookmark, removeBookmark } = useBookmarkStore();
const { isBookmarked, addBookmark, removeBookmark, isArticleBookmarked, addArticleBookmark, removeArticleBookmark } = useBookmarkStore();
const naddr = pendingArticleNaddr ?? "";
@@ -127,7 +127,9 @@ export function ArticleView() {
const bodyHtml = event?.content ? renderMarkdown(event.content) : "";
const wordCount = event?.content?.trim().split(/\s+/).length ?? 0;
const readingTime = Math.max(1, Math.ceil(wordCount / 230));
const bookmarked = event?.id ? isBookmarked(event.id) : false;
const dTag = event?.tags?.find((t) => t[0] === "d")?.[1];
const articleAddr = event && dTag ? `30023:${event.pubkey}:${dTag}` : null;
const bookmarked = articleAddr ? isArticleBookmarked(articleAddr) : (event?.id ? isBookmarked(event.id) : false);
// Reading progress bar + TOC
const scrollRef = useRef<HTMLDivElement>(null);
@@ -198,9 +200,14 @@ export function ArticleView() {
};
const handleBookmark = () => {
if (!event?.id) return;
if (bookmarked) removeBookmark(event.id);
else addBookmark(event.id);
if (!event) return;
if (articleAddr) {
if (bookmarked) removeArticleBookmark(articleAddr);
else addArticleBookmark(articleAddr);
} else if (event.id) {
if (bookmarked) removeBookmark(event.id);
else addBookmark(event.id);
}
};
const handleRepost = async () => {