aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-06 21:23:00 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-06 21:23:35 -0400
commiteb98dfb1a86d42a0ecfe54d8eb978c47aa1c0f8b (patch)
treeba1c9c9f38f8cfba76005a0cb87b3b74a3ac8950 /ext/bg/js/backend.js
parent7db2c661054113966644c9055e5b60e29bbeb068 (diff)
Simplify logic for how option updates are propagated
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index f05ae9e6..b3e737da 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -28,7 +28,7 @@ class Backend {
async prepare() {
await this.translator.prepare();
- await apiOptionsSet(await optionsLoad());
+ this.onOptionsUpdated(await optionsLoad());
if (chrome.commands !== null && typeof chrome.commands === 'object') {
chrome.commands.onCommand.addListener(this.onCommand.bind(this));
@@ -41,7 +41,8 @@ class Backend {
}
onOptionsUpdated(options) {
- this.options = utilIsolate(options);
+ options = utilIsolate(options);
+ this.options = options;
if (!options.general.enable) {
this.setExtensionBadgeBackgroundColor('#555555');
@@ -53,11 +54,7 @@ class Backend {
this.setExtensionBadgeText('');
}
- if (options.anki.enable) {
- this.anki = new AnkiConnect(options.anki.server);
- } else {
- this.anki = new AnkiNull();
- }
+ this.anki = options.anki.enable ? new AnkiConnect(options.anki.server) : new AnkiNull();
const callback = () => this.checkLastError(chrome.runtime.lastError);
chrome.tabs.query({}, tabs => {
@@ -144,7 +141,7 @@ class Backend {
chrome.browserAction.setBadgeBackgroundColor({color});
}
}
-
+
setExtensionBadgeText(text) {
if (typeof chrome.browserAction.setBadgeText === 'function') {
chrome.browserAction.setBadgeText({text});