aboutsummaryrefslogtreecommitdiff
path: root/src/settings/actions
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-09 17:35:10 +0900
committerGitHub <noreply@github.com>2017-10-09 17:35:10 +0900
commit447466808f484d4baa6b285f2dbcaf1920db5498 (patch)
treeaba110eb78b4ce3eb6cefb8100f167e17a23fcc3 /src/settings/actions
parent892eb8a6a6d9080213f461f19a8b8435a6482237 (diff)
parent805d1395fc869235f079438b5b4884a521c0230e (diff)
Merge pull request #27 from ueokande/react-settings
Use React in settings
Diffstat (limited to 'src/settings/actions')
-rw-r--r--src/settings/actions/setting.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/settings/actions/setting.js b/src/settings/actions/setting.js
index 697bcf0..c1b27c8 100644
--- a/src/settings/actions/setting.js
+++ b/src/settings/actions/setting.js
@@ -3,9 +3,9 @@ import messages from 'shared/messages';
import DefaultSettings from 'shared/default-settings';
const load = () => {
- return browser.storage.local.get('settings').then((value) => {
- if (value.settings) {
- return set(value.settings);
+ return browser.storage.local.get('settings').then(({ settings }) => {
+ if (settings) {
+ return set(settings);
}
return set(DefaultSettings);
}, console.error);
@@ -13,10 +13,12 @@ const load = () => {
const save = (settings) => {
return browser.storage.local.set({
- settings
+ settings,
}).then(() => {
return browser.runtime.sendMessage({
type: messages.SETTINGS_RELOAD
+ }).then(() => {
+ return set(settings);
});
});
};
@@ -24,8 +26,10 @@ const save = (settings) => {
const set = (settings) => {
return {
type: actions.SETTING_SET_SETTINGS,
- settings,
+ source: settings.source,
+ json: settings.json,
+ value: JSON.parse(settings.json),
};
};
-export { load, save, set };
+export { load, save };