mirror of
https://github.com/hoornet/vega.git
synced 2026-05-12 22:18:35 -07:00
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:
@@ -79,7 +79,7 @@ export function ArticleView() {
|
|||||||
const [showComment, setShowComment] = useState(false);
|
const [showComment, setShowComment] = useState(false);
|
||||||
const [commentText, setCommentText] = useState("");
|
const [commentText, setCommentText] = useState("");
|
||||||
const autoResize = useAutoResize(3, 10);
|
const autoResize = useAutoResize(3, 10);
|
||||||
const { isBookmarked, addBookmark, removeBookmark } = useBookmarkStore();
|
const { isBookmarked, addBookmark, removeBookmark, isArticleBookmarked, addArticleBookmark, removeArticleBookmark } = useBookmarkStore();
|
||||||
|
|
||||||
const naddr = pendingArticleNaddr ?? "";
|
const naddr = pendingArticleNaddr ?? "";
|
||||||
|
|
||||||
@@ -127,7 +127,9 @@ export function ArticleView() {
|
|||||||
const bodyHtml = event?.content ? renderMarkdown(event.content) : "";
|
const bodyHtml = event?.content ? renderMarkdown(event.content) : "";
|
||||||
const wordCount = event?.content?.trim().split(/\s+/).length ?? 0;
|
const wordCount = event?.content?.trim().split(/\s+/).length ?? 0;
|
||||||
const readingTime = Math.max(1, Math.ceil(wordCount / 230));
|
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
|
// Reading progress bar + TOC
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -198,9 +200,14 @@ export function ArticleView() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleBookmark = () => {
|
const handleBookmark = () => {
|
||||||
if (!event?.id) return;
|
if (!event) return;
|
||||||
if (bookmarked) removeBookmark(event.id);
|
if (articleAddr) {
|
||||||
else addBookmark(event.id);
|
if (bookmarked) removeArticleBookmark(articleAddr);
|
||||||
|
else addArticleBookmark(articleAddr);
|
||||||
|
} else if (event.id) {
|
||||||
|
if (bookmarked) removeBookmark(event.id);
|
||||||
|
else addBookmark(event.id);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRepost = async () => {
|
const handleRepost = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user