mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 06:34:24 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user