Merge pull request #3542 from matrix-org/travis/t3chguy/settings-flags-release

"SettingsFlag always run ToggleSwitch fully controlled" to release
pull/21833/head
Travis Ralston 2019-10-10 14:10:52 +01:00 committed by GitHub
commit c141335b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 11 deletions

View File

@ -30,7 +30,6 @@ module.exports = createReactClass({
label: PropTypes.string, // untranslated
onChange: PropTypes.func,
isExplicit: PropTypes.bool,
manualSave: PropTypes.bool,
},
getInitialState: function() {
@ -47,8 +46,8 @@ module.exports = createReactClass({
onChange: function(checked) {
if (this.props.group && !checked) return;
if (!this.props.manualSave) this.save(checked);
else this.setState({ value: checked });
this.save(checked);
this.setState({ value: checked });
if (this.props.onChange) this.props.onChange(checked);
},
@ -62,13 +61,6 @@ module.exports = createReactClass({
},
render: function() {
const value = this.props.manualSave ? this.state.value : SettingsStore.getValueAt(
this.props.level,
this.props.name,
this.props.roomId,
this.props.isExplicit,
);
const canChange = SettingsStore.canSetValue(this.props.name, this.props.roomId, this.props.level);
let label = this.props.label;
@ -78,7 +70,7 @@ module.exports = createReactClass({
return (
<div className="mx_SettingsFlag">
<span className="mx_SettingsFlag_label">{label}</span>
<ToggleSwitch checked={value} onChange={this.onChange} disabled={!canChange} aria-label={label} />
<ToggleSwitch checked={this.state.value} onChange={this.onChange} disabled={!canChange} aria-label={label} />
</div>
);
},