fix(reads): extract article titles from events using applesauce helpers

- Use getArticleTitle, getArticleSummary, getArticleImage, getArticlePublished from Helpers
- Extract metadata from bookmark.event when available
- Fallback to bookmark fields if event not hydrated
- Fixes 'Untitled' articles in Reads tab
This commit is contained in:
Gigi
2025-10-16 09:01:51 +02:00
parent 7e2b4b46c9
commit e73d89739b

View File

@@ -2,6 +2,9 @@ import { Bookmark, IndividualBookmark } from '../types/bookmarks'
import { ReadItem } from '../services/readsService'
import { classifyBookmarkType } from './bookmarkTypeClassifier'
import { KINDS } from '../config/kinds'
import { Helpers } from 'applesauce-core'
const { getArticleTitle, getArticleImage, getArticlePublished, getArticleSummary } = Helpers
/**
* Derives ReadItems from bookmarks for Nostr articles (kind:30023).
@@ -19,6 +22,12 @@ export function deriveReadsFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
if (bookmarkType === 'article' && bookmark.kind === KINDS.BlogPost) {
const coordinate = bookmark.id // Already in coordinate format
// Extract metadata from event if available
const title = bookmark.event ? getArticleTitle(bookmark.event) : bookmark.title
const summary = bookmark.event ? getArticleSummary(bookmark.event) : bookmark.summary
const image = bookmark.event ? getArticleImage(bookmark.event) : bookmark.image
const published = bookmark.event ? getArticlePublished(bookmark.event) : undefined
const item: ReadItem = {
id: coordinate,
source: 'bookmark',
@@ -26,9 +35,10 @@ export function deriveReadsFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
readingProgress: 0,
readingTimestamp: bookmark.added_at || bookmark.created_at,
event: bookmark.event,
title: bookmark.title,
summary: bookmark.summary,
image: bookmark.image,
title: title || 'Untitled',
summary,
image,
published,
author: bookmark.pubkey,
url: bookmark.url
}