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

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

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