aboutsummaryrefslogtreecommitdiff
path: root/src/content/components
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-05-06 22:30:04 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-05-06 22:30:04 +0900
commit129aae38df1a17a5850898d5832bb8112ead3cbb (patch)
tree30e939b45a1c8a7902e979a03dcd650375ae3dc6 /src/content/components
parent2c366ac3b1d7114869567845c955238e96056565 (diff)
Indicator shows the add-on enabled
Diffstat (limited to 'src/content/components')
-rw-r--r--src/content/components/common/index.js14
-rw-r--r--src/content/components/top-content/index.js7
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,
+ });
}
}
}