load settings from content

This commit is contained in:
Shin'ya Ueoka 2017-10-07 22:31:37 +09:00
parent 8ff302a1f2
commit 30641f1b75
4 changed files with 25 additions and 22 deletions

View file

@ -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();