fix: handle promises properly (2)

This commit is contained in:
thecodrr
2019-12-11 13:35:49 +05:00
parent 7a47f90808
commit d59e67cccb

View File

@@ -358,12 +358,12 @@ function notebookTopicFn(notebookId, topic, fn) {
} }
function topicNoteFn(notebookId, topic, noteId, 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); let topicIndex = notebook.topics.findIndex(t => t.title === topic);
if (topicIndex === -1 || !this.notes.hasOwnProperty(noteId)) return false; if (topicIndex === -1 || !this.notes.hasOwnProperty(noteId)) return false;
if (fn(notebook, topicIndex)) { if ((await fn(notebook, topicIndex)) === true) {
return this.storage.write(KEYS.notes, this.notes).then(s => true); return await this.storage.write(KEYS.notes, this.notes).then(s => true);
} }
return false; return false;
}); });