aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/background/components/indicator.js7
-rw-r--r--src/content/components/common/index.js5
-rw-r--r--src/shared/messages.js1
3 files changed, 12 insertions, 1 deletions
diff --git a/src/background/components/indicator.js b/src/background/components/indicator.js
index ccdcc74..cceb119 100644
--- a/src/background/components/indicator.js
+++ b/src/background/components/indicator.js
@@ -7,6 +7,7 @@ export default class IndicatorComponent {
messages.onMessage(this.onMessage.bind(this));
+ browser.browserAction.onClicked.addListener(this.onClicked);
browser.tabs.onActivated.addListener((info) => {
return browser.tabs.query({ currentWindow: true }).then(() => {
return this.onTabActivated(info);
@@ -22,6 +23,12 @@ export default class IndicatorComponent {
});
}
+ onClicked(tab) {
+ browser.tabs.sendMessage(tab.id, {
+ type: messages.ADDON_TOGGLE_ENABLED,
+ });
+ }
+
onMessage(message) {
switch (message.type) {
case messages.ADDON_ENABLED_RESPONSE:
diff --git a/src/content/components/common/index.js b/src/content/components/common/index.js
index c5d1df7..c76a7d9 100644
--- a/src/content/components/common/index.js
+++ b/src/content/components/common/index.js
@@ -3,6 +3,7 @@ import KeymapperComponent from './keymapper';
import FollowComponent from './follow';
import * as settingActions from 'content/actions/setting';
import messages from 'shared/messages';
+import * as addonActions from '../../actions/addon';
export default class Common {
constructor(win, store) {
@@ -25,7 +26,9 @@ export default class Common {
onMessage(message) {
switch (message.type) {
case messages.SETTINGS_CHANGED:
- this.reloadSettings();
+ return this.reloadSettings();
+ case messages.ADDON_TOGGLE_ENABLED:
+ return this.store.dispatch(addonActions.toggleEnabled());
}
}
diff --git a/src/shared/messages.js b/src/shared/messages.js
index 2a286bf..1f9c816 100644
--- a/src/shared/messages.js
+++ b/src/shared/messages.js
@@ -50,6 +50,7 @@ export default {
ADDON_ENABLED_QUERY: 'addon.enabled.query',
ADDON_ENABLED_RESPONSE: 'addon.enabled.response',
+ ADDON_TOGGLE_ENABLED: 'addon.toggle.enabled',
OPEN_URL: 'open.url',