aboutsummaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/index.js5
-rw-r--r--src/actions/setting.js27
2 files changed, 31 insertions, 1 deletions
diff --git a/src/actions/index.js b/src/actions/index.js
index 2aa28fa..63c36d2 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -13,5 +13,8 @@ export default {
// Completion
COMPLETION_SET_ITEMS: 'completion.set.items',
COMPLETION_SELECT_NEXT: 'completions.select.next',
- COMPLETION_SELECT_PREV: 'completions.select.prev'
+ COMPLETION_SELECT_PREV: 'completions.select.prev',
+
+ // Settings
+ SETTING_SET_SETTINGS: 'setting.set.settings',
};
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 };