reload settings on content
This commit is contained in:
parent
d995ab0030
commit
a6b197ca73
3 changed files with 25 additions and 0 deletions
|
@ -19,6 +19,8 @@ export default class BackgroundComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
browser.tabs.onUpdated.addListener(this.onTabUpdated.bind(this));
|
||||||
|
browser.tabs.onActivated.addListener(this.onTabActivated.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
@ -62,4 +64,22 @@ export default class BackgroundComponent {
|
||||||
this.store.dispatch(settingsActions.load());
|
this.store.dispatch(settingsActions.load());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onTabActivated(info) {
|
||||||
|
this.syncSettings(info.tabId);
|
||||||
|
}
|
||||||
|
|
||||||
|
onTabUpdated(id, info) {
|
||||||
|
if (info.url) {
|
||||||
|
this.syncSettings(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
syncSettings(id) {
|
||||||
|
let { settings } = this.store.getState().setting;
|
||||||
|
return browser.tabs.sendMessage(id, {
|
||||||
|
type: messages.CONTENT_SET_SETTINGS,
|
||||||
|
settings,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import './console-frame.scss';
|
||||||
import * as consoleFrames from './console-frames';
|
import * as consoleFrames from './console-frames';
|
||||||
import * as scrolls from 'content/scrolls';
|
import * as scrolls from 'content/scrolls';
|
||||||
import * as navigates from 'content/navigates';
|
import * as navigates from 'content/navigates';
|
||||||
|
import * as settingActions from 'actions/setting';
|
||||||
import * as followActions from 'actions/follow';
|
import * as followActions from 'actions/follow';
|
||||||
import { createStore } from 'store';
|
import { createStore } from 'store';
|
||||||
import ContentInputComponent from 'components/content-input';
|
import ContentInputComponent from 'components/content-input';
|
||||||
|
@ -64,6 +65,9 @@ browser.runtime.onMessage.addListener((action) => {
|
||||||
case messages.CONTENT_OPERATION:
|
case messages.CONTENT_OPERATION:
|
||||||
execOperation(action.operation);
|
execOperation(action.operation);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
case messages.CONTENT_SET_SETTINGS:
|
||||||
|
store.dispatch(settingActions.set(action.settings));
|
||||||
|
return Promise.resolve();
|
||||||
default:
|
default:
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export default {
|
export default {
|
||||||
CONTENT_OPERATION: 'content.operation',
|
CONTENT_OPERATION: 'content.operation',
|
||||||
|
CONTENT_SET_SETTINGS: 'content.set.settings',
|
||||||
|
|
||||||
CONSOLE_BLURRED: 'console.blured',
|
CONSOLE_BLURRED: 'console.blured',
|
||||||
CONSOLE_ENTERED: 'console.entered',
|
CONSOLE_ENTERED: 'console.entered',
|
||||||
|
|
Reference in a new issue