From e19e9eb96f18efecea4e261cafdb535fb3eb1847 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 31 Jan 2025 11:34:56 +0500 Subject: [PATCH] web: get fresh note context when saving a new note --- apps/web/src/stores/editor-store.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts index 950152ba1..cd8daf419 100644 --- a/apps/web/src/stores/editor-store.ts +++ b/apps/web/src/stores/editor-store.ts @@ -39,7 +39,6 @@ import { isTrashItem, NoteContent } from "@notesnook/core"; -import { Context } from "../components/list-container/types"; import { showToast } from "../utils/toast"; import { getId } from "@notesnook/core"; import { PersistStorage } from "zustand/middleware"; @@ -121,7 +120,6 @@ export type DefaultEditorSession = BaseEditorSession & { export type NewEditorSession = BaseEditorSession & { type: "new"; - context?: Context; saveState: SaveState; content?: NoteContent; }; @@ -908,13 +906,14 @@ class EditorStore extends BaseStore { if (!note) throw new Error("Note not saved."); if (currentSession.type === "new") { - if (currentSession.context) { - const { type } = currentSession.context; + const context = useNoteStore.getState().context; + if (context) { + const { type } = context; if (type === "notebook") - await db.notes.addToNotebook(currentSession.context.id, noteId); + await db.notes.addToNotebook(context.id, noteId); else if (type === "color" || type === "tag") await db.relations.add( - { type, id: currentSession.context.id }, + { type, id: context.id }, { id, type: "note" } ); } else { @@ -1015,7 +1014,6 @@ class EditorStore extends BaseStore { type: "new", id: sessionId, tabId: activeTabId, - context: useNoteStore.getState().context, saveState: SaveState.NotSaved }); };