Skip to content

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

fix: editor saving new note at a new id always

thecodrr386e8c04fdb0
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index 49864fd31..bbf5f436f 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -11,7 +11,10 @@ const DEFAULT_SESSION = {
id: 0,
timeout: undefined,
state: SESSION_STATES.new,
- content: { delta: { ops: [] }, text: "" }
+ title: "",
+ content: { delta: { ops: [] }, text: "" },
+ tags: [],
+ colors: []
};
class EditorStore extends BaseStore {
session = DEFAULT_SESSION;
@@ -25,12 +28,6 @@ class EditorStore extends BaseStore {
openSession = async note => {
clearTimeout(this.session.timeout);
- /* if (note.conflicted) {
- return EditorNavigator.navigate("split", { note });
- } else {
- EditorNavigator.navigate("editor");
- } */
-
let content = {};
if (!note.locked) {
content = {
@@ -55,7 +52,6 @@ class EditorStore extends BaseStore {
saveSession = oldSession => {
this.set(state => (state.session.isSaving = true));
-
this._saveFn(this.session.locked)(this.session).then(id => {
if (!oldSession) {
if (oldSession.tags.length !== this.session.tags.length)
@@ -97,9 +93,11 @@ class EditorStore extends BaseStore {
this.set(state => {
state.session.state = SESSION_STATES.stale;
set(state);
+
state.session.timeout = setTimeout(() => {
+ this.session = this.get().session;
this.saveSession(oldSession);
- }, 500);
+ }, 1000);
});
};
diff --git a/apps/web/src/stores/index.js b/apps/web/src/stores/index.js
index b94a187e0..cca514ac6 100644
--- a/apps/web/src/stores/index.js
+++ b/apps/web/src/stores/index.js
@@ -6,6 +6,7 @@ class BaseStore {
constructor(set, get) {
this.set = set;
this.get = get;
+ this.id = Math.random();
}
}