aboutsummaryrefslogtreecommitdiff
path: root/src/settings/storage.ts
blob: c0005b74c49a33d188f7c8534de1ba7298e13694 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import SettingData, { DefaultSettingData } from '../shared/SettingData';

export const load = async(): Promise<SettingData> => {
  let { settings } = await browser.storage.local.get('settings');
  if (!settings) {
    return DefaultSettingData;
  }
  return SettingData.valueOf(settings as any);
};

export const save = (data: SettingData) => {
  return browser.storage.local.set({
    settings: data.toJSON(),
  });
};