From d59e67cccbe8b38b3ef0b461e3b1e7e36b79d804 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Wed, 11 Dec 2019 13:35:49 +0500 Subject: [PATCH] fix: handle promises properly (2) --- packages/core/api/database.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/api/database.js b/packages/core/api/database.js index 05c64559c..739b2b620 100644 --- a/packages/core/api/database.js +++ b/packages/core/api/database.js @@ -358,12 +358,12 @@ function notebookTopicFn(notebookId, topic, fn) { } function topicNoteFn(notebookId, topic, noteId, fn) { - return notebookTopicFn.call(this, notebookId, topic, notebook => { + return notebookTopicFn.call(this, notebookId, topic, async notebook => { let topicIndex = notebook.topics.findIndex(t => t.title === topic); if (topicIndex === -1 || !this.notes.hasOwnProperty(noteId)) return false; - if (fn(notebook, topicIndex)) { - return this.storage.write(KEYS.notes, this.notes).then(s => true); + if ((await fn(notebook, topicIndex)) === true) { + return await this.storage.write(KEYS.notes, this.notes).then(s => true); } return false; });