Use await/async on settings

jh-changes
Shin'ya Ueoka 7 years ago
parent 7f56a08f3b
commit 94d411234a
  1. 19
      src/settings/actions/setting.js

@ -4,20 +4,17 @@ import DefaultSettings from 'shared/settings/default';
import * as settingsStorage from 'shared/settings/storage'; import * as settingsStorage from 'shared/settings/storage';
import * as settingsValues from 'shared/settings/values'; import * as settingsValues from 'shared/settings/values';
const load = () => { const load = async() => {
return settingsStorage.loadRaw().then((settings) => { let settings = await settingsStorage.loadRaw();
return set(settings); return set(settings);
});
}; };
const save = (settings) => { const save = async(settings) => {
return settingsStorage.save(settings).then(() => { await settingsStorage.save(settings);
return browser.runtime.sendMessage({ await browser.runtime.sendMessage({
type: messages.SETTINGS_RELOAD type: messages.SETTINGS_RELOAD
});
}).then(() => {
return set(settings);
}); });
return set(settings);
}; };
const set = (settings) => { const set = (settings) => {