mirror of
https://github.com/dergigi/boris.git
synced 2026-01-21 15:54:30 +01:00
refactor(bookmarks): never default timestamps to now; allow nulls and sort nulls last; render empty when missing
This commit is contained in:
@@ -343,7 +343,7 @@ class BookmarkController {
|
||||
...b,
|
||||
tags: b.tags || [],
|
||||
content: b.content || this.externalEventStore?.getEvent(b.id)?.content || '', // Fallback to eventStore content
|
||||
created_at: b.created_at || this.externalEventStore?.getEvent(b.id)?.created_at || b.created_at
|
||||
created_at: (b.created_at ?? this.externalEventStore?.getEvent(b.id)?.created_at ?? null)
|
||||
}))
|
||||
|
||||
const sortedBookmarks = enriched
|
||||
@@ -352,9 +352,10 @@ class BookmarkController {
|
||||
urlReferences: extractUrlsFromContent(b.content)
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
// Sort by listUpdatedAt (timestamp of bookmark list event = proxy for when bookmarked)
|
||||
// Newest first (descending)
|
||||
return (b.listUpdatedAt || 0) - (a.listUpdatedAt || 0)
|
||||
// Sort by listUpdatedAt desc, nulls last
|
||||
const aTs = a.listUpdatedAt ?? -Infinity
|
||||
const bTs = b.listUpdatedAt ?? -Infinity
|
||||
return bTs - aTs
|
||||
})
|
||||
|
||||
// DEBUG: Show top 5 sorted bookmarks
|
||||
@@ -370,7 +371,7 @@ class BookmarkController {
|
||||
title: `Bookmarks (${sortedBookmarks.length})`,
|
||||
url: '',
|
||||
content: latestContent,
|
||||
created_at: newestCreatedAt || Math.floor(Date.now() / 1000),
|
||||
created_at: newestCreatedAt || 0,
|
||||
tags: allTags,
|
||||
bookmarkCount: sortedBookmarks.length,
|
||||
eventReferences: allTags.filter((tag: string[]) => tag[0] === 'e').map((tag: string[]) => tag[1]),
|
||||
|
||||
@@ -81,7 +81,7 @@ export const processApplesauceBookmarks = (
|
||||
allItems.push({
|
||||
id: note.id,
|
||||
content: '',
|
||||
created_at: note.created_at || 0,
|
||||
created_at: note.created_at ?? null,
|
||||
pubkey: note.author || activeAccount.pubkey,
|
||||
kind: 1, // Short note kind
|
||||
tags: [],
|
||||
@@ -101,14 +101,14 @@ export const processApplesauceBookmarks = (
|
||||
allItems.push({
|
||||
id: coordinate,
|
||||
content: '',
|
||||
created_at: article.created_at || 0,
|
||||
created_at: article.created_at ?? null,
|
||||
pubkey: article.pubkey,
|
||||
kind: article.kind, // Usually 30023 for long-form articles
|
||||
tags: [],
|
||||
parsedContent: undefined,
|
||||
type: 'event' as const,
|
||||
isPrivate,
|
||||
listUpdatedAt: parentCreatedAt || 0
|
||||
listUpdatedAt: parentCreatedAt ?? null
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -126,7 +126,7 @@ export const processApplesauceBookmarks = (
|
||||
parsedContent: undefined,
|
||||
type: 'event' as const,
|
||||
isPrivate,
|
||||
listUpdatedAt: parentCreatedAt || 0
|
||||
listUpdatedAt: parentCreatedAt ?? null
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -159,14 +159,14 @@ export const processApplesauceBookmarks = (
|
||||
return {
|
||||
id: bookmark.id!,
|
||||
content: bookmark.content || '',
|
||||
created_at: bookmark.created_at || 0,
|
||||
created_at: bookmark.created_at ?? null,
|
||||
pubkey: activeAccount.pubkey,
|
||||
kind: bookmark.kind || 30001,
|
||||
tags: bookmark.tags || [],
|
||||
parsedContent: bookmark.content ? (getParsedContent(bookmark.content) as ParsedContent) : undefined,
|
||||
type: 'event' as const,
|
||||
isPrivate,
|
||||
listUpdatedAt: parentCreatedAt || 0
|
||||
listUpdatedAt: parentCreatedAt ?? null
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ export async function collectBookmarksFromEvents(
|
||||
publicItemsAll.push({
|
||||
id: evt.id,
|
||||
content: evt.content || '',
|
||||
created_at: evt.created_at || Math.floor(Date.now() / 1000),
|
||||
created_at: evt.created_at ?? null,
|
||||
pubkey: evt.pubkey,
|
||||
kind: evt.kind,
|
||||
tags: evt.tags || [],
|
||||
@@ -148,7 +148,7 @@ export async function collectBookmarksFromEvents(
|
||||
setTitle,
|
||||
setDescription,
|
||||
setImage,
|
||||
listUpdatedAt: evt.created_at || Math.floor(Date.now() / 1000)
|
||||
listUpdatedAt: evt.created_at ?? null
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export async function fetchAllReads(
|
||||
source: 'bookmark',
|
||||
type: 'article',
|
||||
readingProgress: 0,
|
||||
readingTimestamp: bookmark.created_at
|
||||
readingTimestamp: bookmark.created_at ?? undefined
|
||||
}
|
||||
readsMap.set(coordinate, item)
|
||||
if (onItem) emitItem(item)
|
||||
|
||||
Reference in New Issue
Block a user