summaryrefslogtreecommitdiff
path: root/ext/bg/js/api.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-07 15:06:15 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-10 20:09:33 -0400
commit8175f80183caa0673a946b2405feae0c9535af48 (patch)
tree9ceb126a6164704aa3bdcfbbdb13d9d89590972b /ext/bg/js/api.js
parent1b2a1e50ebcd62cf54b397516e991333afa5158c (diff)
Remove calls to apiOptionsGetSync
Use apiOptionsGet everywhere to ensure options is initialized.
Diffstat (limited to 'ext/bg/js/api.js')
-rw-r--r--ext/bg/js/api.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 45dc36e7..53e25348 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -17,16 +17,12 @@
*/
-function apiOptionsGetSync(optionsContext) {
+function apiOptionsGet(optionsContext) {
return utilBackend().getOptions(optionsContext);
}
-async function apiOptionsGet(optionsContext) {
- return apiOptionsGetSync(optionsContext);
-}
-
async function apiTermsFind(text, optionsContext) {
- const options = apiOptionsGetSync(optionsContext);
+ const options = await apiOptionsGet(optionsContext);
const translator = utilBackend().translator;
const searcher = {
@@ -49,13 +45,13 @@ async function apiTermsFind(text, optionsContext) {
}
async function apiKanjiFind(text, optionsContext) {
- const options = apiOptionsGetSync(optionsContext);
+ const options = await apiOptionsGet(optionsContext);
const definitions = await utilBackend().translator.findKanji(text, dictEnabledSet(options));
return definitions.slice(0, options.general.maxResults);
}
async function apiDefinitionAdd(definition, mode, context, optionsContext) {
- const options = apiOptionsGetSync(optionsContext);
+ const options = await apiOptionsGet(optionsContext);
if (mode !== 'kanji') {
await audioInject(
@@ -78,7 +74,7 @@ async function apiDefinitionAdd(definition, mode, context, optionsContext) {
}
async function apiDefinitionsAddable(definitions, modes, optionsContext) {
- const options = apiOptionsGetSync(optionsContext);
+ const options = await apiOptionsGet(optionsContext);
const states = [];
try {
@@ -134,7 +130,7 @@ async function apiCommandExec(command) {
toggle: async () => {
const optionsContext = {depth: 0};
- const options = apiOptionsGetSync(optionsContext);
+ const options = await apiOptionsGet(optionsContext);
options.general.enable = !options.general.enable;
await optionsSave(options);
}