aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/api.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-09-08 19:34:39 -0700
committerGitHub <noreply@github.com>2019-09-08 19:34:39 -0700
commitcc53510883b5c5f75069655df6a6733ff1bd002a (patch)
treeeb600ad20c6df3977db962b0a1b94bc566b8ae6f /ext/bg/js/api.js
parentc53263158b22f4be8e54696c4675f360f1813de8 (diff)
parenteb98dfb1a86d42a0ecfe54d8eb978c47aa1c0f8b (diff)
Merge pull request #204 from toasted-nutbread/settings-improvements
Settings improvements
Diffstat (limited to 'ext/bg/js/api.js')
-rw-r--r--ext/bg/js/api.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index b8ef4362..9839aef5 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -17,16 +17,16 @@
*/
-async function apiOptionsSet(options) {
- utilBackend().onOptionsUpdated(options);
+function apiOptionsGetSync() {
+ return utilBackend().options;
}
async function apiOptionsGet() {
- return utilBackend().options;
+ return apiOptionsGetSync();
}
async function apiTermsFind(text) {
- const options = utilBackend().options;
+ const options = apiOptionsGetSync();
const translator = utilBackend().translator;
const searcher = {
@@ -48,13 +48,13 @@ async function apiTermsFind(text) {
}
async function apiKanjiFind(text) {
- const options = utilBackend().options;
+ const options = apiOptionsGetSync();
const definitions = await utilBackend().translator.findKanji(text, dictEnabledSet(options));
return definitions.slice(0, options.general.maxResults);
}
async function apiDefinitionAdd(definition, mode, context) {
- const options = utilBackend().options;
+ const options = apiOptionsGetSync();
if (mode !== 'kanji') {
await audioInject(
@@ -83,7 +83,7 @@ async function apiDefinitionsAddable(definitions, modes) {
const notes = [];
for (const definition of definitions) {
for (const mode of modes) {
- const note = await dictNoteFormat(definition, mode, utilBackend().options);
+ const note = await dictNoteFormat(definition, mode, apiOptionsGetSync());
notes.push(note);
}
}
@@ -131,10 +131,9 @@ async function apiCommandExec(command) {
},
toggle: async () => {
- const options = utilBackend().options;
+ const options = apiOptionsGetSync();
options.general.enable = !options.general.enable;
await optionsSave(options);
- await apiOptionsSet(options);
}
};