From 0ed7c1497fb5b894a239a261340f850d9c87f67b Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 2 Oct 2025 20:56:34 +0200 Subject: [PATCH] feat: sort individual bookmarks by timestamp (newest first) - Sort allBookmarks array by created_at timestamp in descending order - Ensures newest bookmarks appear first in the UI - Maintains chronological order with most recent bookmarks at the top --- src/services/bookmarkService.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/bookmarkService.ts b/src/services/bookmarkService.ts index ab9cbc01..b3e13b58 100644 --- a/src/services/bookmarkService.ts +++ b/src/services/bookmarkService.ts @@ -278,17 +278,20 @@ export const fetchBookmarks = async ( } }) const allBookmarks = [...hydrateItems(publicItemsAll), ...hydrateItems(privateItemsAll)] - + + // Sort individual bookmarks by timestamp (newest first) + const sortedBookmarks = allBookmarks.sort((a, b) => (b.created_at || 0) - (a.created_at || 0)) + const bookmark: Bookmark = { id: `${activeAccount.pubkey}-bookmarks`, - title: `Bookmarks (${allBookmarks.length})`, + title: `Bookmarks (${sortedBookmarks.length})`, url: '', content: latestContent, created_at: newestCreatedAt || Date.now(), tags: allTags, - bookmarkCount: allBookmarks.length, + bookmarkCount: sortedBookmarks.length, eventReferences: allTags.filter(tag => tag[0] === 'e').map(tag => tag[1]), - individualBookmarks: allBookmarks, + individualBookmarks: sortedBookmarks, isPrivate: privateItemsAll.length > 0, encryptedContent: undefined }