Nest ifs to avoid unnecessary work

This commit is contained in:
David Baker 2018-07-27 18:58:11 +01:00
parent e059a08d7b
commit f4c073ad45

View file

@ -259,17 +259,16 @@ const LoggedInView = React.createClass({
// When the panels are disabled, clicking on them results in a mouse event // When the panels are disabled, clicking on them results in a mouse event
// which bubbles to certain elements in the tree. When this happens, close // which bubbles to certain elements in the tree. When this happens, close
// any settings page that is currently open (user/room/group). // any settings page that is currently open (user/room/group).
if (this.props.leftDisabled && this.props.rightDisabled) {
const targetClasses = new Set(ev.target.className.split(' ')); const targetClasses = new Set(ev.target.className.split(' '));
if (this.props.leftDisabled && if (
this.props.rightDisabled &&
(
targetClasses.has('mx_MatrixChat') || targetClasses.has('mx_MatrixChat') ||
targetClasses.has('mx_MatrixChat_middlePanel') || targetClasses.has('mx_MatrixChat_middlePanel') ||
targetClasses.has('mx_RoomView') targetClasses.has('mx_RoomView')
)
) { ) {
dis.dispatch({ action: 'close_settings' }); dis.dispatch({ action: 'close_settings' });
} }
}
}, },
render: function() { render: function() {