A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: handle promise properly
thecodrr7a47f908088d
diff --git a/packages/core/__tests__/database.test.js b/packages/core/__tests__/database.test.jsindex 86cff2cf6..c15110dfc 100644--- a/packages/core/__tests__/database.test.js+++ b/packages/core/__tests__/database.test.js@@ -119,7 +119,7 @@ test("add note to topic", async () => {);let notebook = db.getNotebook(TEST_NOTEBOOK.dateCreated);let topicIndex = notebook.topics.findIndex(t => t.title === "Home");- expect(notebook.topics[topicIndex].notes[0]).toBeGreaterThan(0);+ expect(notebook.topics[topicIndex].notes[0]).toBe(TEST_NOTE.dateCreated);});test("duplicate note to topic should not be added", async () => {diff --git a/packages/core/api/database.js b/packages/core/api/database.jsindex a8c79fe10..05c64559c 100644--- a/packages/core/api/database.js+++ b/packages/core/api/database.js@@ -334,11 +334,26 @@ function deleteItems(items, key) {function notebookTopicFn(notebookId, topic, fn) {if (!notebookId || !topic || !this.notebooks[notebookId]) return false;const notebook = this.notebooks[notebookId];- const result = fn(notebook);- if (result === true) {+ let result = fn(notebook);++ const saveNotebooks = () => {this.notebooks[notebookId] = notebook;return this.storage.write(KEYS.notebooks, this.notebooks).then(s => true);+ };++ if (result instanceof Promise) {+ return result.then(res => {+ if (res === true) {+ return saveNotebooks();+ }+ return false;+ });}++ if (result === true) {+ return saveNotebooks();+ }+return result;}