Simplify how definition count is limited

This commit is contained in:
toasted-nutbread 2019-11-04 20:14:51 -05:00
parent 58c0997999
commit 7093d8f06e

View File

@ -75,16 +75,15 @@ async function apiOptionsSave(source) {
async function apiTermsFind(text, optionsContext) { async function apiTermsFind(text, optionsContext) {
const options = await apiOptionsGet(optionsContext); const options = await apiOptionsGet(optionsContext);
const [definitions, length] = await utilBackend().translator.findTerms(text, options); const [definitions, length] = await utilBackend().translator.findTerms(text, options);
return { definitions.splice(options.general.maxResults);
length, return {length, definitions};
definitions: definitions.slice(0, options.general.maxResults)
};
} }
async function apiKanjiFind(text, optionsContext) { async function apiKanjiFind(text, optionsContext) {
const options = await apiOptionsGet(optionsContext); const options = await apiOptionsGet(optionsContext);
const definitions = await utilBackend().translator.findKanji(text, options); const definitions = await utilBackend().translator.findKanji(text, options);
return definitions.slice(0, options.general.maxResults); definitions.splice(options.general.maxResults);
return definitions;
} }
async function apiDefinitionAdd(definition, mode, context, optionsContext) { async function apiDefinitionAdd(definition, mode, context, optionsContext) {