aboutsummaryrefslogtreecommitdiff
path: root/src/actions/setting.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-01 12:25:49 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-01 12:25:49 +0900
commit1b2554adee528da1078ad39694a3f8264c639821 (patch)
tree0fcacdad33a51cf7611af77e601443eb827c2498 /src/actions/setting.js
parent709fa95aa383b75e88fb12512f772ea55d757b06 (diff)
parent8c9051076f7782b898ab2f848b9afe4a694c3065 (diff)
Merge branch 'settings-validation'
Diffstat (limited to 'src/actions/setting.js')
-rw-r--r--src/actions/setting.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/actions/setting.js b/src/actions/setting.js
new file mode 100644
index 0000000..d8e889e
--- /dev/null
+++ b/src/actions/setting.js
@@ -0,0 +1,27 @@
+import actions from '../actions';
+import messages from '../content/messages';
+
+const load = () => {
+ return browser.storage.local.get('settings').then((value) => {
+ return set(value.settings);
+ }, console.error);
+};
+
+const save = (settings) => {
+ return browser.storage.local.set({
+ settings
+ }).then(() => {
+ return browser.runtime.sendMessage({
+ type: messages.SETTINGS_RELOAD
+ });
+ });
+};
+
+const set = (settings) => {
+ return {
+ type: actions.SETTING_SET_SETTINGS,
+ settings,
+ };
+};
+
+export { load, save, set };