mirror of
https://github.com/dergigi/boris.git
synced 2026-02-21 15:05:00 +01:00
fix(reads): use bookmark.content for article titles
- IndividualBookmark doesn't have separate title/event fields - After hydration, article titles are stored in content field - Simplified extraction logic to just use bookmark.content
This commit is contained in:
@@ -2,13 +2,11 @@ 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).
|
||||
* Returns items with type='article', using hydrated event data when available.
|
||||
* Returns items with type='article', using hydrated data when available.
|
||||
* Note: After hydration, article titles are stored in bookmark.content field.
|
||||
*/
|
||||
export function deriveReadsFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
|
||||
const readsMap = new Map<string, ReadItem>()
|
||||
@@ -22,11 +20,8 @@ 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
|
||||
// After hydration, article title is in bookmark.content
|
||||
const title = bookmark.content || 'Untitled'
|
||||
|
||||
const item: ReadItem = {
|
||||
id: coordinate,
|
||||
@@ -34,13 +29,8 @@ export function deriveReadsFromBookmarks(bookmarks: Bookmark[]): ReadItem[] {
|
||||
type: 'article',
|
||||
readingProgress: 0,
|
||||
readingTimestamp: bookmark.added_at || bookmark.created_at,
|
||||
event: bookmark.event,
|
||||
title: title || 'Untitled',
|
||||
summary,
|
||||
image,
|
||||
published,
|
||||
author: bookmark.pubkey,
|
||||
url: bookmark.url
|
||||
title,
|
||||
author: bookmark.pubkey
|
||||
}
|
||||
|
||||
readsMap.set(coordinate, item)
|
||||
|
||||
Reference in New Issue
Block a user