Ensure toggle switches listen to property changes

They do local echo on changes to avoid jumping back and forth while requests are ongoing, however some areas modify the checked state after the toggle has mounted.

Fixes https://github.com/vector-im/riot-web/issues/8432
This commit is contained in:
Travis Ralston 2019-02-07 11:54:13 -07:00
parent b50bfa1eda
commit 89a8422320

View file

@ -38,6 +38,12 @@ export default class ToggleSwitch extends React.Component {
}; };
} }
componentWillReceiveProps(nextProps) {
if (nextProps.checked !== this.state.checked) {
this.setState({checked: nextProps.checked});
}
}
_onClick = (e) => { _onClick = (e) => {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();