aboutsummaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-09-03 03:11:10 +0000
committerGitHub <noreply@github.com>2019-09-03 03:11:10 +0000
commitab6295d0f136b77534e6e290e165b1035c7abdc2 (patch)
tree5e435a9396979e4307c783f131f251581b955aac /src/settings
parent07bcc15e7b487fb5815b151e8c7e84a31f875dce (diff)
parentf64b7ca320f73dd523113f0eedca35e176843bd6 (diff)
Merge pull request #638 from ueokande/qa-0.24
QA 0.24
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/components/form/PropertiesForm.tsx9
-rw-r--r--src/settings/storage.ts7
2 files changed, 14 insertions, 2 deletions
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<Props> {
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<Props> {
<input type={inputType} name={name}
className='column-input'
value={value[name] ? value[name] : ''}
- onChange={this.bindValue.bind(this)}
+ onChange={onChange}
onBlur={this.props.onBlur}
checked={value[name]}
/>
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<SettingData> => {
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) => {