summaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-15 20:33:20 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-15 20:33:20 -0500
commit496d2599ea6d9607b554641ded77cc82a6b9df42 (patch)
tree115e29e0bd77401294827c1be2637b4b46c7b8a9 /ext/mixed/js/display.js
parentfaf15c08aa6777d1ae2d112c55659e08d53156c6 (diff)
Move error handling for apiDefinitionsAddable
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 045ce906..5c010747 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -414,7 +414,7 @@ class Display {
this.setEventListenersActive(true);
- const states = await apiDefinitionsAddable(definitions, ['term-kanji', 'term-kana'], this.getOptionsContext());
+ const states = await this.getDefinitionsAddable(definitions, ['term-kanji', 'term-kana']);
if (this.setContentToken !== token) { return; }
this.updateAdderButtons(states);
@@ -463,7 +463,7 @@ class Display {
this.setEventListenersActive(true);
- const states = await apiDefinitionsAddable(definitions, ['kanji'], this.getOptionsContext());
+ const states = await this.getDefinitionsAddable(definitions, ['kanji']);
if (this.setContentToken !== token) { return; }
this.updateAdderButtons(states);
@@ -776,6 +776,14 @@ class Display {
return entry !== null ? entry.querySelector('.action-play-audio>img') : null;
}
+ async getDefinitionsAddable(definitions, modes) {
+ try {
+ return await apiDefinitionsAddable(definitions, modes, this.getOptionsContext());
+ } catch (e) {
+ return [];
+ }
+ }
+
static delay(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}