Skip to content

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

fix: handle promises properly (2)

thecodrrd59e67cccbe8
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;
});