fix(bookmarks): sort by display time (created_at || listUpdatedAt) desc; nulls last

This commit is contained in:
Gigi
2025-10-22 13:07:37 +02:00
parent 2e955e9bed
commit 2e0a493243
2 changed files with 5 additions and 10 deletions

View File

@@ -352,9 +352,9 @@ class BookmarkController {
urlReferences: extractUrlsFromContent(b.content)
}))
.sort((a, b) => {
// Sort by listUpdatedAt desc, nulls last
const aTs = a.listUpdatedAt ?? -Infinity
const bTs = b.listUpdatedAt ?? -Infinity
// Sort by display time: created_at, else listUpdatedAt. Newest first. Nulls last.
const aTs = (a.created_at ?? a.listUpdatedAt ?? -Infinity)
const bTs = (b.created_at ?? b.listUpdatedAt ?? -Infinity)
return bTs - aTs
})

View File

@@ -87,13 +87,8 @@ export const renderParsedContent = (parsedContent: ParsedContent) => {
// Sorting and grouping for bookmarks
export const sortIndividualBookmarks = (items: IndividualBookmark[]) => {
return items
.slice()
.sort((a, b) => {
const aTs = a.listUpdatedAt ?? -Infinity
const bTs = b.listUpdatedAt ?? -Infinity
return bTs - aTs
})
const getSortTime = (b: IndividualBookmark) => b.created_at ?? b.listUpdatedAt ?? -Infinity
return items.slice().sort((a, b) => getSortTime(b) - getSortTime(a))
}
export function groupIndividualBookmarks(items: IndividualBookmark[]) {