diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-06-21 15:54:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-21 15:54:34 -0400 |
commit | 0c69e54fde259568ebd89a3c9e8481cf28860ea8 (patch) | |
tree | a472ac24e87a3718d80cb4a9903f74357d804e28 /ext/bg/js/backend.js | |
parent | 9e6153f172fd9043eaa34cd2de639ce2b9c3f4a3 (diff) |
Optimize anki note field generation (#611)
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r-- | ext/bg/js/backend.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 93ba620f..a8ee9f83 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -579,13 +579,14 @@ class Backend { const states = []; try { - const notes = []; + const notePromises = []; for (const definition of definitions) { for (const mode of modes) { - const note = await this.ankiNoteBuilder.createNote(definition, mode, context, options, templates); - notes.push(note); + const notePromise = this.ankiNoteBuilder.createNote(definition, mode, context, options, templates); + notePromises.push(notePromise); } } + const notes = await Promise.all(notePromises); const cannotAdd = []; const results = await this.anki.canAddNotes(notes); |