separate settings
This commit is contained in:
parent
541449b1fc
commit
58123210ab
13 changed files with 17 additions and 34 deletions
31
src/settings/actions/setting.js
Normal file
31
src/settings/actions/setting.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import actions from 'settings/actions';
|
||||
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 set(DefaultSettings);
|
||||
}, 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