summaryrefslogtreecommitdiff
path: root/ext/bg/js/api.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-08-19 17:30:38 -0700
committerAlex Yatskov <alex@foosoft.net>2017-08-19 17:30:38 -0700
commitd5b4b0499842023fab57a8231d7e0eb80737deab (patch)
tree54470d711f4fd6cc25a0befeb6ff36e8aa28bb8e /ext/bg/js/api.js
parent6a2e272f116c539ddd0fbf474509537d6b4529af (diff)
parentbecf549dcec03b1a5aff8ff9033fc7d14b8a2541 (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/bg/js/api.js')
-rw-r--r--ext/bg/js/api.js31
1 files changed, 18 insertions, 13 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 2afe82a0..96147d95 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -66,22 +66,27 @@ async function apiDefinitionAdd(definition, mode) {
}
async function apiDefinitionsAddable(definitions, modes) {
- const notes = [];
- for (const definition of definitions) {
- for (const mode of modes) {
- notes.push(dictNoteFormat(definition, mode, utilBackend().options));
- }
- }
-
- const results = await utilBackend().anki.canAddNotes(notes);
const states = [];
- for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
- const state = {};
- for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
- state[modes[modeOffset]] = results[resultBase + modeOffset];
+
+ try {
+ const notes = [];
+ for (const definition of definitions) {
+ for (const mode of modes) {
+ notes.push(dictNoteFormat(definition, mode, utilBackend().options));
+ }
}
- states.push(state);
+ const results = await utilBackend().anki.canAddNotes(notes);
+ for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
+ const state = {};
+ for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
+ state[modes[modeOffset]] = results[resultBase + modeOffset];
+ }
+
+ states.push(state);
+ }
+ } catch (e) {
+ // NOP
}
return states;