diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-24 02:02:23 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-24 02:02:23 +0100 |
commit | 219d49355c48eceaecd99fda804996e12fd1ac97 (patch) | |
tree | c67084d9a880a52b7559cb7bc4119dc7db08d981 /frontend/src/redux/currentGame.js | |
parent | Add prepare move actions (diff) | |
download | seven-wonders-219d49355c48eceaecd99fda804996e12fd1ac97.tar.gz seven-wonders-219d49355c48eceaecd99fda804996e12fd1ac97.tar.bz2 seven-wonders-219d49355c48eceaecd99fda804996e12fd1ac97.zip |
Reset current turn when executed so that people can say ready again
Diffstat (limited to 'frontend/src/redux/currentGame.js')
-rw-r--r-- | frontend/src/redux/currentGame.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/frontend/src/redux/currentGame.js b/frontend/src/redux/currentGame.js index f4174eca..e5659195 100644 --- a/frontend/src/redux/currentGame.js +++ b/frontend/src/redux/currentGame.js @@ -10,6 +10,7 @@ export function createCurrentGameReducer() { return combineReducers({ readyUsernames: readyUsernamesReducer, turnInfo: turnInfoReducer, + table: tableUpdatesReducer, }); } @@ -22,18 +23,24 @@ const readyUsernamesReducer = (state: List<string> = new List(), action: Action) }; const turnInfoReducer = (state: ApiPlayerTurnInfo | null = null, action: Action) => { - if (action.type === types.TURN_INFO_RECEIVED) { - return action.turnInfo; - } else { - return state; + switch (action.type) { + case types.TURN_INFO_RECEIVED: + return action.turnInfo; + case types.TABLE_UPDATE_RECEIVED: + return null; + default: + return state; } }; -const tableUpdatesReducer = (state: ApiTable, action: Action) => { - if (action.type === types.TABLE_UPDATE_RECEIVED) { - return action.table; - } else { - return state; +const tableUpdatesReducer = (state: ApiTable | null = null, action: Action) => { + switch (action.type) { + case types.TURN_INFO_RECEIVED: + return action.turnInfo.table; + case types.TABLE_UPDATE_RECEIVED: + return action.table; + default: + return state; } }; |