From eb16282f15034ea48f2715be83d56430dbdcaa8f Mon Sep 17 00:00:00 2001 From: thecodrr Date: Tue, 10 May 2022 13:57:01 +0500 Subject: [PATCH] fix: overlapping note contents when quickly switching (fixes streetwriters/notesnook#561) --- apps/web/src/components/editor/index.js | 2 +- apps/web/src/stores/editor-store.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js index feed8b1b9..89ea09b0c 100644 --- a/apps/web/src/components/editor/index.js +++ b/apps/web/src/components/editor/index.js @@ -278,7 +278,7 @@ function Editor({ noteId, nonce }) { sessionId={sessionId} onChange={(content, editor) => { const { id, sessionId } = editorstore.get().session; - debouncedOnEditorChange(sessionId, id, sessionId, content); + debouncedOnEditorChange(id, id, sessionId, content); debouncedUpdateWordCount(editor); }} changeInterval={100} diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js index b8acdef8b..14a5c266e 100644 --- a/apps/web/src/stores/editor-store.js +++ b/apps/web/src/stores/editor-store.js @@ -174,6 +174,8 @@ class EditorStore extends BaseStore { } this.set((state) => { + if (state.session.id !== note.id) return; + for (let key in session) { if (key === "content") continue; state.session[key] = session[key];