diff options
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/components/common/index.js | 14 | ||||
-rw-r--r-- | src/content/components/top-content/index.js | 7 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/content/components/common/index.js b/src/content/components/common/index.js index 565632c..c5d1df7 100644 --- a/src/content/components/common/index.js +++ b/src/content/components/common/index.js @@ -14,10 +14,12 @@ export default class Common { input.onKey(key => keymapper.key(key)); this.store = store; + this.prevEnabled = this.store.getState().addon.enabled; this.reloadSettings(); messages.onMessage(this.onMessage.bind(this)); + store.subscribe(() => this.update()); } onMessage(message) { @@ -27,6 +29,18 @@ export default class Common { } } + update() { + let enabled = this.store.getState().addon.enabled; + if (enabled !== this.prevEnabled) { + this.prevEnabled = enabled; + + browser.runtime.sendMessage({ + type: messages.ADDON_ENABLED_RESPONSE, + enabled, + }); + } + } + reloadSettings() { browser.runtime.sendMessage({ type: messages.SETTINGS_QUERY, diff --git a/src/content/components/top-content/index.js b/src/content/components/top-content/index.js index cf21ec4..cb9e160 100644 --- a/src/content/components/top-content/index.js +++ b/src/content/components/top-content/index.js @@ -48,11 +48,18 @@ export default class TopContent { } onMessage(message) { + let addonState = this.store.getState().addon; + switch (message.type) { case messages.CONSOLE_UNFOCUS: this.win.focus(); consoleFrames.blur(window.document); return Promise.resolve(); + case messages.ADDON_ENABLED_QUERY: + return Promise.resolve({ + type: messages.ADDON_ENABLED_RESPONSE, + enabled: addonState.enabled, + }); } } } |