mirror of https://github.com/vector-im/riot-web
Merge pull request #3542 from matrix-org/travis/t3chguy/settings-flags-release
"SettingsFlag always run ToggleSwitch fully controlled" to releasepull/21833/head
commit
c141335b6a
|
@ -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>
|
||||
);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue