diff options
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/containers/app.js | 2 | ||||
-rw-r--r-- | frontend/src/containers/home.js | 4 | ||||
-rw-r--r-- | frontend/src/reducers.js | 4 | ||||
-rw-r--r-- | frontend/src/redux/players.js (renamed from frontend/src/redux/user.js) | 14 | ||||
-rw-r--r-- | frontend/src/sagas/gameBrowser.js | 6 | ||||
-rw-r--r-- | frontend/src/sagas/usernameChoice.js | 2 |
6 files changed, 18 insertions, 14 deletions
diff --git a/frontend/src/containers/app.js b/frontend/src/containers/app.js index adfc557f..40602efc 100644 --- a/frontend/src/containers/app.js +++ b/frontend/src/containers/app.js @@ -49,7 +49,7 @@ class App extends Component { } const mapStateToProps = (state) => ({ - username: state.user.get('displayName') + username: state.players.get('all').get(state.players.get('current')).get('username') }) diff --git a/frontend/src/containers/home.js b/frontend/src/containers/home.js index cc35f2bc..fe9bd373 100644 --- a/frontend/src/containers/home.js +++ b/frontend/src/containers/home.js @@ -22,6 +22,8 @@ class HomePage extends Component { onChange={(e) => this._username = e.target.value} onClick={this.play} /> + <Link to="/games">/games</Link> + <br /> <Link to="/somewhere">Take me somewhere</Link> </div> ) @@ -32,7 +34,7 @@ const mapStateToProps = (state) => ({ }) -import { actions } from '../redux/user' +import { actions } from '../redux/players' const mapDispatchToProps = { chooseUsername: actions.chooseUsername } diff --git a/frontend/src/reducers.js b/frontend/src/reducers.js index 5cc01ec9..c280c8a7 100644 --- a/frontend/src/reducers.js +++ b/frontend/src/reducers.js @@ -2,12 +2,12 @@ import { combineReducers } from 'redux' import { routerReducer } from 'react-router-redux' import gamesReducer from './redux/game' -import userReducer from './redux/user' +import playersReducer from './redux/players' export default function createReducer() { return combineReducers({ games: gamesReducer, routing: routerReducer, - user: userReducer, + players: playersReducer, }) } diff --git a/frontend/src/redux/user.js b/frontend/src/redux/players.js index 9046cc97..e49d4bbf 100644 --- a/frontend/src/redux/user.js +++ b/frontend/src/redux/players.js @@ -17,17 +17,19 @@ export const actions = { const initialState = fromJS({ - username: '', - displayName: '', - id: null + all: {}, + current: null }) export default (state = initialState, action) => { switch (action.type) { case types.SET_USERNAME: - return state.set('username', action.username) - .set('displayName', action.displayName) - .set('index', action.index) + const user = fromJS({ + username: action.username, + displayName: action.displayName, + index: action.index, + }) + return state.setIn(['all', user.get('username')], user).set('current', user.get('username')) default: return state } diff --git a/frontend/src/sagas/gameBrowser.js b/frontend/src/sagas/gameBrowser.js index 19d52df9..5b7227df 100644 --- a/frontend/src/sagas/gameBrowser.js +++ b/frontend/src/sagas/gameBrowser.js @@ -25,7 +25,7 @@ function gameBrowserChannel(socket) { }) } -export function* watchGames({ socket }) { +export function *watchGames({ socket }) { const socketChannel = gameBrowserChannel(socket) try { @@ -50,13 +50,13 @@ export function* watchGames({ socket }) { } } -export function* createGame({ socket }) { +export function *createGame({ socket }) { const { name } = yield take(types.CREATE_GAME) socket.send("/app/lobby/create", JSON.stringify({ gameName: name }), {}) } -export function* gameBrowserSaga(socketConnection) { +export function *gameBrowserSaga(socketConnection) { yield [ call(watchGames, socketConnection), call(createGame, socketConnection) diff --git a/frontend/src/sagas/usernameChoice.js b/frontend/src/sagas/usernameChoice.js index d0d0cdea..e9812c72 100644 --- a/frontend/src/sagas/usernameChoice.js +++ b/frontend/src/sagas/usernameChoice.js @@ -2,7 +2,7 @@ import { call, take, put } from 'redux-saga/effects' import { eventChannel } from 'redux-saga' import { push } from 'react-router-redux' -import { actions, types } from '../redux/user' +import { actions, types } from '../redux/players' function usernameValidationChannel(socket) { return eventChannel(emitter => { |