diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-03-20 16:24:38 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-03-20 16:25:30 +0100 |
commit | 6be2de249c494370283bb2a23a48500ed6e2871b (patch) | |
tree | c5deac45d311aa780f9bba8dde95eb54ce82ad22 /src/client/react/components/container/RoomFinder.js | |
parent | 9470394383bb0105053937a149472189940016df (diff) |
Move switching setting user to a room code to Menu
This ensures tapping the room finder button always works, even when no
room is selected in the first place.
Diffstat (limited to 'src/client/react/components/container/RoomFinder.js')
-rw-r--r-- | src/client/react/components/container/RoomFinder.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/client/react/components/container/RoomFinder.js b/src/client/react/components/container/RoomFinder.js index 5f25fd7..97ed175 100644 --- a/src/client/react/components/container/RoomFinder.js +++ b/src/client/react/components/container/RoomFinder.js @@ -26,7 +26,7 @@ import { Button, ButtonIcon } from 'rmwc/Button'; import users from '../../users'; import { setUser, userFromMatch } from '../../lib/url'; -class HelpBox extends React.Component { +class RoomFinder extends React.Component { static propTypes = { // redux isVisible: PropTypes.bool.isRequired, @@ -46,23 +46,17 @@ class HelpBox extends React.Component { componentWillMount() { const user = userFromMatch(this.props.match); - // Have we just been mounted and are we viewing something else then a room? if (this.props.isVisible && users.byId[user].type !== 'r') { + // We are not currently viewing a room, so just hide. this.props.dispatch({ type: 'ROOM_FINDER/HIDE' }); } } componentWillReceiveProps(nextProps) { const user = userFromMatch(nextProps.match); - // We are not currently viewing a room, correct the situation. if (nextProps.isVisible && users.byId[user].type !== 'r') { - // Did we just become visible? Set the user to a room. If not, hide. - if (!this.props.isVisible) { - // Set the room to the first room. - setUser(users.allRoomIds[0], nextProps.location, nextProps.history); - } else { - this.props.dispatch({ type: 'ROOM_FINDER/HIDE' }); - } + // We are not currently viewing a room, so just hide. + this.props.dispatch({ type: 'ROOM_FINDER/HIDE' }); } } @@ -106,4 +100,4 @@ const mapStateToProps = state => ({ isVisible: state.isRoomFinderVisible, }); -export default withRouter(connect(mapStateToProps)(HelpBox)); +export default withRouter(connect(mapStateToProps)(RoomFinder)); |