From d623abd20c070b7736f66793b8f921a0ad7cb27f Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 7 Sep 2025 16:00:03 +0000 Subject: fix: fix tag flicker caused by tag sorting --- packages/trpc/models/bookmarks.ts | 6 ++++++ packages/trpc/routers/bookmarks.ts | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/trpc/models/bookmarks.ts b/packages/trpc/models/bookmarks.ts index 07b3832d..e0864ec1 100644 --- a/packages/trpc/models/bookmarks.ts +++ b/packages/trpc/models/bookmarks.ts @@ -342,6 +342,12 @@ export class Bookmark implements PrivacyAware { } }); + bookmarksArr.forEach((b) => { + b.tags.sort((a, b) => + a.attachedBy === "ai" ? 1 : b.attachedBy === "ai" ? -1 : 0, + ); + }); + let nextCursor = null; if (bookmarksArr.length > input.limit) { const nextItem = bookmarksArr.pop()!; diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index db9d33fc..31ffef4a 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -240,10 +240,14 @@ async function toZodSchema( } return { - tags: tagsOnBookmarks.map((t) => ({ - attachedBy: t.attachedBy, - ...t.tag, - })), + tags: tagsOnBookmarks + .map((t) => ({ + attachedBy: t.attachedBy, + ...t.tag, + })) + .sort((a, b) => + a.attachedBy === "ai" ? 1 : b.attachedBy === "ai" ? -1 : 0, + ), content, assets: assets.map((a) => ({ id: a.id, -- cgit v1.2.3-70-g09d2