aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-07 22:31:37 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-07 22:31:37 +0900
commit30641f1b75a2a21b3bc3b3605bae634be7e809c9 (patch)
treec92aeb1b23acd26f8420fa4bd68869b53c769b47 /src/content
parent8ff302a1f2870994cddc36fd461879eac951203d (diff)
load settings from content
Diffstat (limited to 'src/content')
-rw-r--r--src/content/index.js15
-rw-r--r--src/content/messages.js3
2 files changed, 14 insertions, 4 deletions
diff --git a/src/content/index.js b/src/content/index.js
index 09143b0..a2e3e3d 100644
--- a/src/content/index.js
+++ b/src/content/index.js
@@ -21,16 +21,25 @@ store.subscribe(() => {
consoleFrames.initialize(window.document);
+const reloadSettings = () => {
+ return browser.runtime.sendMessage({
+ type: messages.SETTINGS_QUERY,
+ }).then((settings) => {
+ store.dispatch(settingActions.set(settings));
+ });
+};
+
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
case messages.CONSOLE_HIDE:
window.focus();
consoleFrames.blur(window.document);
return Promise.resolve();
- case messages.CONTENT_SET_SETTINGS:
- store.dispatch(settingActions.set(action.settings));
- return Promise.resolve();
+ case messages.SETTINGS_CHANGED:
+ return reloadSettings();
default:
return Promise.resolve();
}
});
+
+reloadSettings();
diff --git a/src/content/messages.js b/src/content/messages.js
index eb056a7..138f0e0 100644
--- a/src/content/messages.js
+++ b/src/content/messages.js
@@ -1,5 +1,6 @@
export default {
- CONTENT_SET_SETTINGS: 'content.set.settings',
+ SETTINGS_QUERY: 'settings.query',
+
BACKGROUND_OPERATION: 'background.operation',
CONSOLE_BLURRED: 'console.blured',