diff options
| author | MohamedBassem <me@mbassem.com> | 2024-07-01 11:29:28 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-07-01 11:29:28 +0000 |
| commit | 3d495cd16aff9e37a8db27ae4ee88c0fbad93122 (patch) | |
| tree | df917b0c8fcac9c46d4b2e84569f8380af887b55 /packages/trpc/routers/bookmarks.ts | |
| parent | e6486465decd612f7e437abe904960a47ff359ce (diff) | |
| download | karakeep-3d495cd16aff9e37a8db27ae4ee88c0fbad93122.tar.zst | |
fix: Fix duplicate bookmarks in links with assets
Diffstat (limited to '')
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index edf196bb..d0ffc7d3 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -601,7 +601,11 @@ export const bookmarksAppRouter = router({ }; } - if (row.bookmarkTags) { + if ( + row.bookmarkTags && + // Duplicates may accur because of the join, so we need to make sure we're not adding the same tag twice + !acc[bookmarkId].tags.some((t) => t.id == row.bookmarkTags!.id) + ) { invariant( row.tagsOnBookmarks, "if bookmark tag is set, its many-to-many relation must also be set", |
