Move apiKanjiFind implementation into Backend

This commit is contained in:
toasted-nutbread 2019-12-09 21:13:03 -05:00
parent 8dff73679e
commit 5cceba15e2
2 changed files with 7 additions and 7 deletions

View File

@ -105,11 +105,8 @@ async function apiTextParseMecab(text, optionsContext) {
return results; return results;
} }
async function apiKanjiFind(text, optionsContext) { function apiKanjiFind(text, optionsContext) {
const options = await apiOptionsGet(optionsContext); return utilBackend()._onApiKanjiFind({text, optionsContext});
const definitions = await utilBackend().translator.findKanji(text, options);
definitions.splice(options.general.maxResults);
return definitions;
} }
async function apiDefinitionAdd(definition, mode, context, optionsContext) { async function apiDefinitionAdd(definition, mode, context, optionsContext) {

View File

@ -240,8 +240,11 @@ class Backend {
this.onOptionsUpdated(source); this.onOptionsUpdated(source);
} }
_onApiKanjiFind({text, optionsContext}) { async _onApiKanjiFind({text, optionsContext}) {
return apiKanjiFind(text, optionsContext); const options = await this.getOptions(optionsContext);
const definitions = await this.translator.findKanji(text, options);
definitions.splice(options.general.maxResults);
return definitions;
} }
_onApiTermsFind({text, details, optionsContext}) { _onApiTermsFind({text, details, optionsContext}) {