Move error handling for apiDefinitionsAddable
This commit is contained in:
parent
faf15c08aa
commit
496d2599ea
@ -58,7 +58,7 @@ function apiDefinitionAdd(definition, mode, context, optionsContext) {
|
||||
}
|
||||
|
||||
function apiDefinitionsAddable(definitions, modes, optionsContext) {
|
||||
return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext}).catch(() => null);
|
||||
return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext});
|
||||
}
|
||||
|
||||
function apiNoteView(noteId) {
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user