From 94d411234ada47bef2c8f4a3b0fc77904f0900a6 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 17 Jun 2018 21:56:54 +0900 Subject: Use await/async on settings --- src/settings/actions/setting.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/settings') diff --git a/src/settings/actions/setting.js b/src/settings/actions/setting.js index 92c9f8a..1219ba5 100644 --- a/src/settings/actions/setting.js +++ b/src/settings/actions/setting.js @@ -4,20 +4,17 @@ import DefaultSettings from 'shared/settings/default'; import * as settingsStorage from 'shared/settings/storage'; import * as settingsValues from 'shared/settings/values'; -const load = () => { - return settingsStorage.loadRaw().then((settings) => { - return set(settings); - }); +const load = async() => { + let settings = await settingsStorage.loadRaw(); + return set(settings); }; -const save = (settings) => { - return settingsStorage.save(settings).then(() => { - return browser.runtime.sendMessage({ - type: messages.SETTINGS_RELOAD - }); - }).then(() => { - return set(settings); +const save = async(settings) => { + await settingsStorage.save(settings); + await browser.runtime.sendMessage({ + type: messages.SETTINGS_RELOAD }); + return set(settings); }; const set = (settings) => { -- cgit v1.2.3