From 67e02cd9cb772a6b37e0d0fff3131d8ef4657d45 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Wed, 28 Aug 2019 22:06:48 +0900 Subject: Use default settings on loading failure --- src/settings/storage.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/settings') diff --git a/src/settings/storage.ts b/src/settings/storage.ts index c0005b7..32b6351 100644 --- a/src/settings/storage.ts +++ b/src/settings/storage.ts @@ -5,7 +5,12 @@ export const load = async(): Promise => { if (!settings) { return DefaultSettingData; } - return SettingData.valueOf(settings as any); + try { + return SettingData.valueOf(settings as any); + } catch (e) { + console.error('unable to load settings', e); + return DefaultSettingData; + } }; export const save = (data: SettingData) => { -- cgit v1.2.3 From f719ce52a36024887e4976082c2ef2b136f2f5ca Mon Sep 17 00:00:00 2001 From: Shin'ya UEOKA Date: Thu, 29 Aug 2019 04:23:42 +0000 Subject: Save on checkbox changed --- src/settings/components/form/PropertiesForm.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/settings') diff --git a/src/settings/components/form/PropertiesForm.tsx b/src/settings/components/form/PropertiesForm.tsx index 0be5f5c..ee98b7e 100644 --- a/src/settings/components/form/PropertiesForm.tsx +++ b/src/settings/components/form/PropertiesForm.tsx @@ -25,12 +25,19 @@ class PropertiesForm extends React.Component { Object.keys(types).map((name) => { let type = types[name]; let inputType = ''; + let onChange = this.bindValue.bind(this); if (type === 'string') { inputType = 'text'; } else if (type === 'number') { inputType = 'number'; } else if (type === 'boolean') { inputType = 'checkbox'; + + // Settings are saved onBlur, but checkbox does not fire it + onChange = (e) => { + this.bindValue(e); + this.props.onBlur(); + }; } else { return null; } @@ -40,7 +47,7 @@ class PropertiesForm extends React.Component { -- cgit v1.2.3