Skip to content

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

web: fix editor margins state reset on restart

Abdullah Attaa38fe7da438c
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts
index da0d8b88f..ba7ff8f01 100644
--- a/apps/web/src/stores/editor-store.ts
+++ b/apps/web/src/stores/editor-store.ts
@@ -936,19 +936,19 @@ class EditorStore extends BaseStore<EditorStore> {
};
toggleTableOfContents = (toggleState?: boolean) => {
- this.set((state) => {
- state.isTOCVisible =
- toggleState !== undefined ? toggleState : !state.isTOCVisible;
- Config.set("editor:toc", !state.isTOCVisible);
- });
+ const { isTOCVisible } = this.get();
+ const isTOCVisibleState =
+ toggleState !== undefined ? toggleState : !isTOCVisible;
+ this.set({ isTOCVisible: isTOCVisibleState });
+ Config.set("editor:toc", isTOCVisibleState);
};
toggleEditorMargins = (toggleState?: boolean) => {
- this.set((state) => {
- state.editorMargins =
- toggleState !== undefined ? toggleState : !state.editorMargins;
- Config.set("editor:margins", state.editorMargins);
- });
+ const { editorMargins } = this.get();
+ const editorMarginsState =
+ toggleState !== undefined ? toggleState : !editorMargins;
+ this.set({ editorMargins: editorMarginsState });
+ Config.set("editor:margins", editorMarginsState);
};
}