Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: crash on assigning a tag from editor

Abdullah Atta632291e90179
diff --git a/apps/web/src/components/editor/header.tsx b/apps/web/src/components/editor/header.tsx
index 0b32c1e8f..f59457af5 100644
--- a/apps/web/src/components/editor/header.tsx
+++ b/apps/web/src/components/editor/header.tsx
@@ -50,7 +50,9 @@ function Header(props: HeaderProps) {
if (oldTag) {
await db.relations.unlink(oldTag, { type: "note", id: noteId });
} else {
- const id = await db.tags.add({ title: value });
+ const id =
+ (await db.tags.find(value))?.id ??
+ (await db.tags.add({ title: value }));
await db.relations.add(
{ id, type: "tag" },
{ type: "note", id: noteId }