diff options
Diffstat (limited to 'packages/trpc')
| -rw-r--r-- | packages/trpc/models/bookmarks.ts | 6 | ||||
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 12 |
2 files changed, 14 insertions, 4 deletions
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, |
