You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

38 lines
965 B

import InputComponent from './input';
import KeymapperComponent from './keymapper';
import FollowComponent from './follow';
import * as settingActions from 'content/actions/setting';
import messages from 'shared/messages';
export default class Common {
constructor(win, store) {
const follow = new FollowComponent(win, store);
const input = new InputComponent(win.document.body, store);
const keymapper = new KeymapperComponent(store);
input.onKey(key => follow.key(key));
input.onKey(key => keymapper.key(key));
this.store = store;
this.reloadSettings();
messages.onMessage(this.onMessage.bind(this));
}
onMessage(message) {
switch (message.type) {
case messages.SETTINGS_CHANGED:
this.reloadSettings();
}
}
reloadSettings() {
browser.runtime.sendMessage({
type: messages.SETTINGS_QUERY,
}).then((settings) => {
this.store.dispatch(settingActions.set(settings));
});
}
}