setting as redux
This commit is contained in:
parent
709fa95aa3
commit
61806a4e7f
6 changed files with 112 additions and 19 deletions
27
src/actions/setting.js
Normal file
27
src/actions/setting.js
Normal file
|
@ -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 };
|
Reference in a new issue