From 219d49355c48eceaecd99fda804996e12fd1ac97 Mon Sep 17 00:00:00 2001 From: jbion Date: Sun, 24 Feb 2019 02:02:23 +0100 Subject: Reset current turn when executed so that people can say ready again --- frontend/src/redux/currentGame.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'frontend/src/redux/currentGame.js') 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 = 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; } }; -- cgit