diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-27 03:12:55 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-27 03:12:55 +0100 |
commit | 8d73d21108738754efd07b63ecc7368fd49502fa (patch) | |
tree | 8755dd1aa9c61e9f473fd6787ba8f3595006f0fa /frontend/src/redux/currentGame.js | |
parent | Remove unnecessary Jackson annotation on non-DTOs (diff) | |
download | seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.tar.gz seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.tar.bz2 seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.zip |
Simplify state and reducers
Diffstat (limited to 'frontend/src/redux/currentGame.js')
-rw-r--r-- | frontend/src/redux/currentGame.js | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/frontend/src/redux/currentGame.js b/frontend/src/redux/currentGame.js index e5659195..e315a1e8 100644 --- a/frontend/src/redux/currentGame.js +++ b/frontend/src/redux/currentGame.js @@ -1,27 +1,22 @@ // @flow -import { List } from 'immutable'; import { combineReducers } from 'redux'; import type { ApiPlayerTurnInfo, ApiTable } from '../api/model'; -import { CurrentGameState } from '../models/currentGame'; +import type { GlobalState } from '../reducers'; import type { Action } from './actions/all'; import { types } from './actions/game'; +export type CurrentGameState = { + turnInfo: ApiPlayerTurnInfo | null; + table: ApiTable | null; +} + export function createCurrentGameReducer() { return combineReducers({ - readyUsernames: readyUsernamesReducer, turnInfo: turnInfoReducer, table: tableUpdatesReducer, }); } -const readyUsernamesReducer = (state: List<string> = new List(), action: Action) => { - if (action.type === types.PLAYER_READY_RECEIVED) { - return state.push(action.username); - } else { - return state; - } -}; - const turnInfoReducer = (state: ApiPlayerTurnInfo | null = null, action: Action) => { switch (action.type) { case types.TURN_INFO_RECEIVED: @@ -44,4 +39,4 @@ const tableUpdatesReducer = (state: ApiTable | null = null, action: Action) => { } }; -export const getCurrentTurnInfo = (state: CurrentGameState): ApiPlayerTurnInfo => state.turnInfo; +export const getCurrentTurnInfo = (state: GlobalState): ApiPlayerTurnInfo => state.currentGame.turnInfo; |