diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-01 10:59:47 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-01 11:09:29 +0900 |
commit | 61806a4e7ff01e8b5fdfdcef0308a2c41fc98778 (patch) | |
tree | 0aa0588c7380d88cfa7d394856cd07a153e61dcf /src/pages/settings.js | |
parent | 709fa95aa383b75e88fb12512f772ea55d757b06 (diff) |
setting as redux
Diffstat (limited to 'src/pages/settings.js')
-rw-r--r-- | src/pages/settings.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/pages/settings.js b/src/pages/settings.js index 6e00ed3..9bad967 100644 --- a/src/pages/settings.js +++ b/src/pages/settings.js @@ -1,22 +1,15 @@ import './settings.scss'; -import messages from '../content/messages'; +import SettingComponent from '../components/setting'; +import settingReducer from '../reducers/setting'; +import * as store from '../store'; -document.addEventListener('DOMContentLoaded', () => { - let form = document.getElementById('vimvixen-settings-form'); - form.addEventListener('submit', (e) => { - e.preventDefault(); - browser.storage.local.set({ - settings: { - json: e.target.elements['plain-json'].value - } - }).then(() => { - return browser.runtime.sendMessage({ - type: messages.SETTINGS_RELOAD - }); - }); - }); +const settingStore = store.createStore(settingReducer); +let settingComponent = null; + +settingStore.subscribe(() => { + settingComponent.update(); +}); - browser.storage.local.get('settings').then((value) => { - form.elements['plain-json'].value = value.settings.json; - }, console.error); +document.addEventListener('DOMContentLoaded', () => { + settingComponent = new SettingComponent(document.body, settingStore); }); |