diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-06-26 21:46:41 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-06-26 21:46:41 +0200 |
commit | 315adeb5e2012b7f7bcfcd1478f9d6dd2cc1092d (patch) | |
tree | 17ecdc44866845b679ca69337041856df3cab33c /src/client/react/components/container/RoomFinder.js | |
parent | d95009ed42a3a94c947bccbed8a436cbf6b9306c (diff) |
Update code to comply with new styling
Diffstat (limited to 'src/client/react/components/container/RoomFinder.js')
-rw-r--r-- | src/client/react/components/container/RoomFinder.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/client/react/components/container/RoomFinder.js b/src/client/react/components/container/RoomFinder.js index b729ee3..0d296a2 100644 --- a/src/client/react/components/container/RoomFinder.js +++ b/src/client/react/components/container/RoomFinder.js @@ -41,24 +41,29 @@ class RoomFinder extends React.Component { } componentWillMount() { - const user = userFromMatch(this.props.match); - if (this.props.isVisible && users.byId[user].type !== 'r') { + const { isVisible, match, dispatch } = this.props; + const user = userFromMatch(match); + + if (isVisible && users.byId[user].type !== 'r') { // We are not currently viewing a room, so just hide. - this.props.dispatch({ type: 'ROOM_FINDER/HIDE' }); + dispatch({ type: 'ROOM_FINDER/HIDE' }); } } componentWillReceiveProps(nextProps) { - const user = userFromMatch(nextProps.match); - if (nextProps.isVisible && users.byId[user].type !== 'r') { + const { isVisible, match, dispatch } = nextProps; + + const user = userFromMatch(match); + if (isVisible && users.byId[user].type !== 'r') { // We are not currently viewing a room, so just hide. - this.props.dispatch({ type: 'ROOM_FINDER/HIDE' }); + dispatch({ type: 'ROOM_FINDER/HIDE' }); } } changeRoom(change) { + const { match, location, history } = this.props; const { allRoomIds } = users; - const currentRoom = userFromMatch(this.props.match); + const currentRoom = userFromMatch(match); const currentRoomIndex = allRoomIds.indexOf(currentRoom); let nextRoomIndex = currentRoomIndex + change; if (nextRoomIndex < 0) { @@ -68,22 +73,27 @@ class RoomFinder extends React.Component { } const nextRoom = allRoomIds[nextRoomIndex]; - setUser(nextRoom, this.props.location, this.props.history); + setUser(nextRoom, location, history); } render() { - if (!this.props.isVisible) { + const { isVisible, dispatch } = this.props; + if (!isVisible) { return <div />; } return ( <div className="RoomFinder"> - <Button onClick={() => this.changeRoom(-1)}>Vorige</Button> - <Button onClick={() => this.changeRoom(+1)}>Volgende</Button> + <Button onClick={() => this.changeRoom(-1)}> + Vorige + </Button> + <Button onClick={() => this.changeRoom(+1)}> + Volgende + </Button> <div className="grow" /> <Button className="closeButton" - onClick={() => this.props.dispatch({ type: 'ROOM_FINDER/HIDE' })} + onClick={() => dispatch({ type: 'ROOM_FINDER/HIDE' })} > <ButtonIcon use="close" /> </Button> |