summaryrefslogtreecommitdiff
path: root/sw-ui/src/redux/games.ts
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-04-06 18:55:25 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-04-06 18:55:58 +0200
commitd4d20533556928f63c8759437f67e76336bab55e (patch)
tree34e7bb151b5d21497665131b6ab8d875254e7666 /sw-ui/src/redux/games.ts
parentRefactoring in GameScene.kt (diff)
downloadseven-wonders-d4d20533556928f63c8759437f67e76336bab55e.tar.gz
seven-wonders-d4d20533556928f63c8759437f67e76336bab55e.tar.bz2
seven-wonders-d4d20533556928f63c8759437f67e76336bab55e.zip
Delete old React/TypeScript UI
Diffstat (limited to 'sw-ui/src/redux/games.ts')
-rw-r--r--sw-ui/src/redux/games.ts56
1 files changed, 0 insertions, 56 deletions
diff --git a/sw-ui/src/redux/games.ts b/sw-ui/src/redux/games.ts
deleted file mode 100644
index 4df2f1da..00000000
--- a/sw-ui/src/redux/games.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { List, Map } from 'immutable';
-import { combineReducers } from 'redux';
-import { ApiLobby } from '../api/model';
-import { GlobalState } from '../reducers';
-import { Action } from './actions/all';
-import { ENTER_LOBBY, UPDATE_GAMES } from './actions/lobby';
-
-export type GamesState = {
- all: Map<string, ApiLobby>,
- current: string | null
-};
-
-export const EMPTY_GAMES: GamesState = {
- all: Map(),
- current: null,
-};
-
-export const createGamesReducer = () => {
- return combineReducers({
- all: allGamesReducer,
- current: currentGameIdReducer
- })
-};
-
-export const allGamesReducer = (state: Map<string, ApiLobby> = Map(), action: Action) => {
- switch (action.type) {
- case UPDATE_GAMES:
- const newGames = mapify(action.games);
- return state.merge(newGames);
- default:
- return state;
- }
-};
-
-function mapify(games: ApiLobby[]): Map<string, ApiLobby> {
- let newGames: {[id:string]:ApiLobby} = {};
- games.forEach(g => newGames[`${g.id}`] = g);
- return Map(newGames);
-}
-
-export const currentGameIdReducer = (state: string | null = null, action: Action) => {
- switch (action.type) {
- case ENTER_LOBBY:
- return `${action.gameId}`;
- default:
- return state;
- }
-};
-
-export const getAllGames = (state: GlobalState): List<ApiLobby> => state.games.all.toList();
-export const getCurrentGame = (state: GlobalState): ApiLobby | null => {
- if (state.games.current == null) {
- return null;
- }
- return state.games.all.get(state.games.current) || null;
-};
bgstack15