setting as redux

This commit is contained in:
Shin'ya Ueoka 2017-10-01 10:59:47 +09:00
parent 709fa95aa3
commit 61806a4e7f
6 changed files with 112 additions and 19 deletions

31
src/components/setting.js Normal file
View file

@ -0,0 +1,31 @@
import * as settingActions from '../actions/setting';
export default class SettingComponent {
constructor(wrapper, store) {
this.wrapper = wrapper;
this.store = store;
let doc = wrapper.ownerDocument;
let form = doc.getElementById('vimvixen-settings-form');
form.addEventListener('submit', this.onSubmit.bind(this));
store.dispatch(settingActions.load());
}
onSubmit(e) {
let settings = {
json: e.target.elements['plain-json'].value,
};
this.store.dispatch(settingActions.save(settings));
e.preventDefault();
}
update() {
let { settings } = this.store.getState();
let doc = this.wrapper.ownerDocument;
let form = doc.getElementById('vimvixen-settings-form');
let plainJsonInput = form.elements['plain-json'];
plainJsonInput.value = settings.json;
}
}