aboutsummaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/actions/setting.js12
-rw-r--r--src/settings/components/setting.js3
-rw-r--r--src/settings/reducers/setting.js10
3 files changed, 15 insertions, 10 deletions
diff --git a/src/settings/actions/setting.js b/src/settings/actions/setting.js
index 697bcf0..3525f0a 100644
--- a/src/settings/actions/setting.js
+++ b/src/settings/actions/setting.js
@@ -4,8 +4,9 @@ import DefaultSettings from 'shared/default-settings';
const load = () => {
return browser.storage.local.get('settings').then((value) => {
- if (value.settings) {
- return set(value.settings);
+ let settings = value.settings;
+ if (settings) {
+ return set(settings);
}
return set(DefaultSettings);
}, console.error);
@@ -13,7 +14,7 @@ const load = () => {
const save = (settings) => {
return browser.storage.local.set({
- settings
+ settings,
}).then(() => {
return browser.runtime.sendMessage({
type: messages.SETTINGS_RELOAD
@@ -24,8 +25,9 @@ const save = (settings) => {
const set = (settings) => {
return {
type: actions.SETTING_SET_SETTINGS,
- settings,
+ json: settings.json,
+ value: JSON.parse(settings.json),
};
};
-export { load, save, set };
+export { load, save };
diff --git a/src/settings/components/setting.js b/src/settings/components/setting.js
index 14482a3..cf1538f 100644
--- a/src/settings/components/setting.js
+++ b/src/settings/components/setting.js
@@ -35,11 +35,12 @@ export default class SettingComponent {
}
update() {
- let { settings } = this.store.getState();
+ 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;
+
}
}
diff --git a/src/settings/reducers/setting.js b/src/settings/reducers/setting.js
index f7d9242..7f32f72 100644
--- a/src/settings/reducers/setting.js
+++ b/src/settings/reducers/setting.js
@@ -1,15 +1,17 @@
import actions from 'settings/actions';
const defaultState = {
- settings: {}
+ json: '',
+ value: {}
};
export default function reducer(state = defaultState, action = {}) {
switch (action.type) {
case actions.SETTING_SET_SETTINGS:
- return Object.assign({}, state, {
- settings: action.settings,
- });
+ return {
+ json: action.json,
+ value: action.value,
+ };
default:
return state;
}