summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/models/currentGame.js5
-rw-r--r--frontend/src/redux/currentGame.js25
2 files changed, 19 insertions, 11 deletions
diff --git a/frontend/src/models/currentGame.js b/frontend/src/models/currentGame.js
index 6ff00858..398c65e8 100644
--- a/frontend/src/models/currentGame.js
+++ b/frontend/src/models/currentGame.js
@@ -1,7 +1,8 @@
import { List } from 'immutable';
-import type { ApiPlayerTurnInfo } from '../api/model';
+import type { ApiPlayerTurnInfo, ApiTable } from '../api/model';
export class CurrentGameState {
readyUsernames: List<string> = new List();
- turnInfo: ApiPlayerTurnInfo | null = null
+ turnInfo: ApiPlayerTurnInfo | null = null;
+ table: ApiTable | null = null;
}
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