diff options
-rw-r--r-- | src/main/js/src/containers/GameBrowser/index.js | 8 | ||||
-rw-r--r-- | src/main/js/src/containers/GameBrowser/reducer.js | 2 | ||||
-rw-r--r-- | src/main/js/src/containers/GameBrowser/saga.js | 5 |
3 files changed, 7 insertions, 8 deletions
diff --git a/src/main/js/src/containers/GameBrowser/index.js b/src/main/js/src/containers/GameBrowser/index.js index f9b3b29c..9deb720b 100644 --- a/src/main/js/src/containers/GameBrowser/index.js +++ b/src/main/js/src/containers/GameBrowser/index.js @@ -6,11 +6,9 @@ import { Text, Space } from 'rebass' class GameBrowser extends Component { listGames = (games) => { - return Object.keys(games).map(key => { - const game = games[key] - console.log('game', game, key) - return (<Flex key={key}> - <Text>{game.name}</Text> + return games.valueSeq().map((game, index) => { + return (<Flex key={index}> + <Text>{game.get('name')}</Text> <Space auto /> <a href="#">Join</a> </Flex>) diff --git a/src/main/js/src/containers/GameBrowser/reducer.js b/src/main/js/src/containers/GameBrowser/reducer.js index ef05d290..4fb3390a 100644 --- a/src/main/js/src/containers/GameBrowser/reducer.js +++ b/src/main/js/src/containers/GameBrowser/reducer.js @@ -6,7 +6,7 @@ const initialState = Map({}) export default function reducer(state = initialState, action) { switch (action.type) { case NEW_GAME: - return Map.set(action.game.id, action.game) + return state.set(action.game.get('id'), action.game) default: return state } diff --git a/src/main/js/src/containers/GameBrowser/saga.js b/src/main/js/src/containers/GameBrowser/saga.js index f28f5562..29115a2b 100644 --- a/src/main/js/src/containers/GameBrowser/saga.js +++ b/src/main/js/src/containers/GameBrowser/saga.js @@ -1,5 +1,6 @@ import { call, put, take } from 'redux-saga/effects' import { eventChannel } from 'redux-saga' +import { fromJS } from 'immutable' import { NEW_GAME, JOIN_GAME, CREATE_GAME } from './constants' import { newGame, joinGame } from './actions' @@ -7,7 +8,7 @@ import { newGame, joinGame } from './actions' function createSocketChannel(socket) { return eventChannel(emit => { const makeHandler = (type) => (event) => { - const response = JSON.parse(event.body) + const response = fromJS(JSON.parse(event.body)) emit({ type, @@ -54,7 +55,7 @@ export function* watchGames(socketConnection) { export function* createGame(socketConnection) { const { name } = yield take(CREATE_GAME) const { socket } = socketConnection - console.log(socket) + socket.send("/app/lobby/create-game", JSON.stringify({ 'gameName': name, 'playerName': 'Cesar92' |