aboutsummaryrefslogtreecommitdiff
path: root/src/actions/setting.js
blob: d8e889e7062b5e1210f48ef17fcd4c9606537fce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 };