diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-07 21:16:47 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 21:16:47 +0900 |
commit | 05ef6a8ca35aaa801c11eb6b4896caa3690058af (patch) | |
tree | 2c7708ca91ac2b462cc86aa28612e3d3943496f3 /src/settings/actions/setting.js | |
parent | 457d954e08923b4accd28a919c72d0b61db1bb98 (diff) | |
parent | 27d0a7f37d24a0ad68a8ccb7dee18fc1d00eea58 (diff) |
Merge pull request #578 from ueokande/move-to-typescript
Move to TypeScript
Diffstat (limited to 'src/settings/actions/setting.js')
-rw-r--r-- | src/settings/actions/setting.js | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/settings/actions/setting.js b/src/settings/actions/setting.js deleted file mode 100644 index db63a45..0000000 --- a/src/settings/actions/setting.js +++ /dev/null @@ -1,63 +0,0 @@ -import actions from 'settings/actions'; -import * as validator from 'shared/settings/validator'; -import * as settingsValues from 'shared/settings/values'; -import * as settingsStorage from 'shared/settings/storage'; -import keymaps from '../keymaps'; - -const load = async() => { - let settings = await settingsStorage.loadRaw(); - return set(settings); -}; - -const save = async(settings) => { - try { - if (settings.source === 'json') { - let value = JSON.parse(settings.json); - validator.validate(value); - } - } catch (e) { - return { - type: actions.SETTING_SHOW_ERROR, - error: e.toString(), - json: settings.json, - }; - } - await settingsStorage.save(settings); - return set(settings); -}; - -const switchToForm = (json) => { - try { - validator.validate(JSON.parse(json)); - let form = settingsValues.formFromJson(json, keymaps.allowedOps); - return { - type: actions.SETTING_SWITCH_TO_FORM, - form, - }; - } catch (e) { - return { - type: actions.SETTING_SHOW_ERROR, - error: e.toString(), - json, - }; - } -}; - -const switchToJson = (form) => { - let json = settingsValues.jsonFromForm(form); - return { - type: actions.SETTING_SWITCH_TO_JSON, - json, - }; -}; - -const set = (settings) => { - return { - type: actions.SETTING_SET_SETTINGS, - source: settings.source, - json: settings.json, - form: settings.form, - }; -}; - -export { load, save, set, switchToForm, switchToJson }; |