Refactor the infamous three-valued boolean into two booleans, trying to simplify the logic

This commit is contained in:
Thibaut Girka
2018-03-28 15:40:34 +02:00
parent 259bc9840b
commit 2888f74c12
5 changed files with 49 additions and 41 deletions

View File

@ -22,15 +22,15 @@ export default class StatusIcons extends React.PureComponent {
mediaIcon: PropTypes.string,
collapsible: PropTypes.bool,
collapsed: PropTypes.bool,
setExpansion: PropTypes.func.isRequired,
setCollapsed: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
// Handles clicks on collapsed button
handleCollapsedClick = (e) => {
const { collapsed, setExpansion } = this.props;
const { collapsed, setCollapsed } = this.props;
if (e.button === 0) {
setExpansion(collapsed ? null : false);
setCollapsed(!collapsed);
e.preventDefault();
}
}