Use await/async on shared directory

jh-changes
Shin'ya Ueoka 7 years ago
parent 94d411234a
commit b74acf6f6a
  1. 10
      src/shared/settings/storage.js
  2. 5
      src/shared/versions/index.js
  3. 5
      src/shared/versions/storage.js

@ -1,17 +1,16 @@
import DefaultSettings from './default';
import * as settingsValues from './values';
const loadRaw = () => {
return browser.storage.local.get('settings').then(({ settings }) => {
const loadRaw = async() => {
let { settings } = await browser.storage.local.get('settings');
if (!settings) {
return DefaultSettings;
}
return Object.assign({}, DefaultSettings, settings);
});
};
const loadValue = () => {
return loadRaw().then((settings) => {
const loadValue = async() => {
let settings = await loadRaw();
let value = JSON.parse(DefaultSettings.json);
if (settings.source === 'json') {
value = settingsValues.valueFromJson(settings.json);
@ -24,7 +23,6 @@ const loadValue = () => {
return Object.assign({},
settingsValues.valueFromJson(DefaultSettings.json),
value);
});
};
const save = (settings) => {

@ -13,13 +13,12 @@ const notificationClickListener = (id) => {
browser.notifications.onClicked.removeListener(notificationClickListener);
};
const checkUpdated = () => {
return storage.load().then((prev) => {
const checkUpdated = async() => {
let prev = await storage.load();
if (!prev) {
return true;
}
return manifest.version !== prev;
});
};
const notify = () => {

@ -1,7 +1,6 @@
const load = () => {
return browser.storage.local.get('version').then(({ version }) => {
const load = async() => {
let { version } = await browser.storage.local.get('version');
return version;
});
};
const save = (version) => {