Skip to content

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

web: cache editor content before saving

Abdullah Attab94af68265e1
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index 8423411b2..ad480d961 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -145,7 +145,7 @@ export default function EditorManager({
if (!isOldSession) return;
openSession(noteId);
- }, [openSession, noteId, isOldSession, isReadonly]);
+ }, [noteId]);
return (
<Flex
@@ -295,8 +295,7 @@ function EditorChrome(props: PropsWithChildren<EditorProps>) {
<Toolbar />
<FlexScrollContainer
className="editorScroll"
- style={{}}
- viewStyle={{ display: "flex", flexDirection: "column" }}
+ style={{ display: "flex", flexDirection: "column" }}
>
<Flex
variant="columnFill"
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index 853bb3016..2c55d591d 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -161,6 +161,8 @@ class EditorStore extends BaseStore {
this.setSaveState(0);
try {
+ if (session.content) this.get().session.content = session.content;
+
const id = await this._getSaveFn()({ ...session, id: sessionId });
if (currentSession && currentSession.id !== sessionId) {
noteStore.refresh();
@@ -196,9 +198,6 @@ class EditorStore extends BaseStore {
attachmentStore.refresh();
}
- if (session.content) {
- this.get().session.content = session.content;
- }
this.set((state) => {
if (!!state.session.id && state.session.id !== note.id) return;