Skip to content

Commit

Permalink
Dispatch push when ROOM_CREATE_SUCCESS
Browse files Browse the repository at this point in the history
  • Loading branch information
GBS-Skile committed Jun 19, 2019
1 parent 22cfe91 commit 985c13c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions frontend/src/containers/RoomCreatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const RoomCreatePageContainer = (props) => {
if ( !username ) {
return <Redirect to="/" />
}
else if( room ) {
return <Redirect to={`/room/${room.url}/`}/>
}
// else if( room ) {
// return <Redirect to={`/room/${room.url}/`}/>
// }
else {
return <RoomCreatePage {...props} />
}
}

const mapStateToProps = state => ({
room: state.room.room,
// room: state.room.room,
username: state.user.username,
token: state.user.token,
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/store/room/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const roomReducer = (state = initialState, action) => {
case actions.ROOM_CREATE_SUCCESS:
return {
...state,
room: action.room,
// room: action.room,
roomList: [
...state.roomList,
action.room,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/store/room/sagas.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { push } from 'connected-react-router'
import { fork, takeEvery, put } from 'redux-saga/effects'
import { toastr } from 'react-redux-toastr'
import api from 'services/api'
Expand Down Expand Up @@ -27,6 +28,7 @@ function* roomCreateRequest({ roomname, members, username, token }){
{ icon: 'success', status: 'success', }
)
yield put(actions.roomCreateSuccess(room))
yield put(push(`/room/${room.url}/`))
} catch(e) {
console.log(e)
}
Expand Down

0 comments on commit 985c13c

Please sign in to comment.