diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/background/actions/index.js | 1 | ||||
-rw-r--r-- | src/background/actions/setting.js | 10 | ||||
-rw-r--r-- | src/background/reducers/setting.js | 9 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/background/actions/index.js b/src/background/actions/index.js index 8c212c2..efe4074 100644 --- a/src/background/actions/index.js +++ b/src/background/actions/index.js @@ -1,4 +1,5 @@ export default { // Settings SETTING_SET_SETTINGS: 'setting.set.settings', + SETTING_SET_PROPERTY: 'setting.set.property', }; diff --git a/src/background/actions/setting.js b/src/background/actions/setting.js index 0454a68..773142f 100644 --- a/src/background/actions/setting.js +++ b/src/background/actions/setting.js @@ -10,4 +10,12 @@ const load = () => { }); }; -export { load }; +const setProperty = (name, value) => { + return { + type: actions.SETTING_SET_PROPERTY, + name, + value, + }; +}; + +export { load, setProperty }; diff --git a/src/background/reducers/setting.js b/src/background/reducers/setting.js index 70bf8ea..045a654 100644 --- a/src/background/reducers/setting.js +++ b/src/background/reducers/setting.js @@ -1,4 +1,4 @@ -import actions from 'settings/actions'; +import actions from 'background/actions'; const defaultState = { value: {}, @@ -10,6 +10,13 @@ export default function reducer(state = defaultState, action = {}) { return { value: action.value, }; + case actions.SETTING_SET_PROPERTY: + return { + value: Object.assign({}, state.value, { + properties: Object.assign({}, state.value.properties, + { [action.name]: action.value }) + }) + }; default: return state; } |