Move apiTermsFind implementation into Backend

This commit is contained in:
toasted-nutbread 2019-12-09 21:15:37 -05:00
parent 5cceba15e2
commit 73ce2fe3d3
2 changed files with 7 additions and 7 deletions

View File

@ -33,11 +33,8 @@ function apiOptionsSave(source) {
return utilBackend()._onApiOptionsSave({source}); return utilBackend()._onApiOptionsSave({source});
} }
async function apiTermsFind(text, details, optionsContext) { function apiTermsFind(text, details, optionsContext) {
const options = await apiOptionsGet(optionsContext); return utilBackend()._onApiTermsFind({text, details, optionsContext});
const [definitions, length] = await utilBackend().translator.findTerms(text, details, options);
definitions.splice(options.general.maxResults);
return {length, definitions};
} }
async function apiTextParse(text, optionsContext) { async function apiTextParse(text, optionsContext) {

View File

@ -247,8 +247,11 @@ class Backend {
return definitions; return definitions;
} }
_onApiTermsFind({text, details, optionsContext}) { async _onApiTermsFind({text, details, optionsContext}) {
return apiTermsFind(text, details, optionsContext); const options = await this.getOptions(optionsContext);
const [definitions, length] = await this.translator.findTerms(text, details, options);
definitions.splice(options.general.maxResults);
return {length, definitions};
} }
_onApiTextParse({text, optionsContext}) { _onApiTextParse({text, optionsContext}) {