From 61806a4e7ff01e8b5fdfdcef0308a2c41fc98778 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 1 Oct 2017 10:59:47 +0900 Subject: setting as redux --- src/actions/setting.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/actions/setting.js (limited to 'src/actions/setting.js') 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 }; -- cgit v1.2.3