From 744642e2b768457acc83719b0d7835c0c4fdc77c Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 7 Oct 2025 05:25:50 +0100 Subject: [PATCH] fix: ensure bookmarks are sorted newest first after merging lists - Re-sort all individual bookmarks after flattening from multiple lists - Sort by added_at first, then fall back to created_at - Prevents interleaving of sorted lists from breaking overall order - Ensures newest bookmarks always appear at the top --- src/components/BookmarkList.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/BookmarkList.tsx b/src/components/BookmarkList.tsx index 2caced83..d0f95aae 100644 --- a/src/components/BookmarkList.tsx +++ b/src/components/BookmarkList.tsx @@ -37,9 +37,10 @@ export const BookmarkList: React.FC = ({ loading = false }) => { // Merge and flatten all individual bookmarks from all lists - // They're already sorted by date in the service layer + // Re-sort after flattening to ensure newest first across all lists const allIndividualBookmarks = bookmarks.flatMap(b => b.individualBookmarks || []) .filter(ib => ib.content || ib.kind === 30023 || ib.kind === 39701) + .sort((a, b) => ((b.added_at || 0) - (a.added_at || 0)) || ((b.created_at || 0) - (a.created_at || 0))) if (isCollapsed) { // Check if the selected URL is in bookmarks