Skip to content

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

web: fix new notes not getting assigned to default notebook

Abdullah Atta82fc6d31c38d
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts
index 909bae920..b832d1f39 100644
--- a/apps/web/src/stores/editor-store.ts
+++ b/apps/web/src/stores/editor-store.ts
@@ -732,23 +732,24 @@ class EditorStore extends BaseStore<EditorStore> {
});
}
- const defaultNotebook = db.settings.getDefaultNotebook();
- if (currentSession.type === "new" && currentSession.context) {
- const { type } = currentSession.context;
- if (type === "notebook")
- await db.notes.addToNotebook(currentSession.context.id, id);
- else if (type === "color" || type === "tag")
- await db.relations.add(
- { type, id: currentSession.context.id },
- { id, type: "note" }
- );
- } else if (!id && defaultNotebook) {
- await db.notes.addToNotebook(defaultNotebook, id);
- }
-
const note = await db.notes.note(id);
if (!note) throw new Error("Note not saved.");
+ if (currentSession.type === "new") {
+ if (currentSession.context) {
+ const { type } = currentSession.context;
+ if (type === "notebook")
+ await db.notes.addToNotebook(currentSession.context.id, id);
+ else if (type === "color" || type === "tag")
+ await db.relations.add(
+ { type, id: currentSession.context.id },
+ { id, type: "note" }
+ );
+ }
+ const defaultNotebook = db.settings.getDefaultNotebook();
+ if (defaultNotebook) await db.notes.addToNotebook(defaultNotebook, id);
+ }
+
const attachmentsLength = await db.attachments.ofNote(id, "all").count();
const shouldRefreshNotes =
currentSession.type === "new" ||