summaryrefslogtreecommitdiff
path: root/frontend/src/redux
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/redux')
-rw-r--r--frontend/src/redux/currentGame.js25
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;
}
};
bgstack15