summaryrefslogtreecommitdiff
path: root/frontend/src/redux/actions
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2019-02-27 03:12:55 +0100
committerjbion <joffrey.bion@amadeus.com>2019-02-27 03:12:55 +0100
commit8d73d21108738754efd07b63ecc7368fd49502fa (patch)
tree8755dd1aa9c61e9f473fd6787ba8f3595006f0fa /frontend/src/redux/actions
parentRemove unnecessary Jackson annotation on non-DTOs (diff)
downloadseven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.tar.gz
seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.tar.bz2
seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.zip
Simplify state and reducers
Diffstat (limited to 'frontend/src/redux/actions')
-rw-r--r--frontend/src/redux/actions/all.js2
-rw-r--r--frontend/src/redux/actions/lobby.js7
-rw-r--r--frontend/src/redux/actions/user.js (renamed from frontend/src/redux/actions/players.js)14
3 files changed, 9 insertions, 14 deletions
diff --git a/frontend/src/redux/actions/all.js b/frontend/src/redux/actions/all.js
index 45d3ab7a..12522819 100644
--- a/frontend/src/redux/actions/all.js
+++ b/frontend/src/redux/actions/all.js
@@ -1,5 +1,5 @@
import type { GameAction } from './game';
import type { LobbyAction } from './lobby';
-import type { PlayerAction } from './players';
+import type { PlayerAction } from './user';
export type Action = PlayerAction | LobbyAction | GameAction
diff --git a/frontend/src/redux/actions/lobby.js b/frontend/src/redux/actions/lobby.js
index b3151a23..8768ec80 100644
--- a/frontend/src/redux/actions/lobby.js
+++ b/frontend/src/redux/actions/lobby.js
@@ -1,5 +1,4 @@
-import { fromJS } from 'immutable';
-import type { GameMapType, GameNormalMapType } from '../../models/games';
+import type { ApiLobby } from '../../api/model';
export const types = {
UPDATE_GAMES: 'GAMES/UPDATE_GAMES',
@@ -10,7 +9,7 @@ export const types = {
ENTER_GAME: 'GAMES/ENTER_GAME',
};
-export type UpdateGamesAction = { type: 'GAMES/UPDATE_GAMES', games: GameMapType };
+export type UpdateGamesAction = { type: 'GAMES/UPDATE_GAMES', games: ApiLobby[]};
export type RequestCreateGameAction = { type: 'GAMES/REQUEST_CREATE_GAME', gameName: string };
export type RequestJoinGameAction = { type: 'GAMES/REQUEST_JOIN_GAME', gameId: number };
export type RequestStartGameAction = { type: 'GAMES/REQUEST_START_GAME' };
@@ -26,7 +25,7 @@ export type LobbyAction =
| EnterGameAction;
export const actions = {
- updateGames: (games: GameNormalMapType): UpdateGamesAction => ({ type: types.UPDATE_GAMES, games: fromJS(games) }),
+ updateGames: (games: ApiLobby[]): UpdateGamesAction => ({ type: types.UPDATE_GAMES, games }),
requestJoinGame: (gameId: number): RequestJoinGameAction => ({ type: types.REQUEST_JOIN_GAME, gameId }),
requestCreateGame: (gameName: string): RequestCreateGameAction => ({ type: types.REQUEST_CREATE_GAME, gameName }),
requestStartGame: (): RequestStartGameAction => ({ type: types.REQUEST_START_GAME }),
diff --git a/frontend/src/redux/actions/players.js b/frontend/src/redux/actions/user.js
index 7df174c4..4406230b 100644
--- a/frontend/src/redux/actions/players.js
+++ b/frontend/src/redux/actions/user.js
@@ -1,5 +1,5 @@
import { Map } from 'immutable';
-import { PlayerShape } from '../../models/players';
+import type { ApiPlayer } from '../../api/model';
export const types = {
REQUEST_CHOOSE_USERNAME: 'USER/REQUEST_CHOOSE_USERNAME',
@@ -8,8 +8,8 @@ export const types = {
};
export type RequestChooseUsernameAction = { type: types.REQUEST_CHOOSE_USERNAME, username: string };
-export type SetCurrentPlayerAction = { type: types.SET_CURRENT_PLAYER, player: PlayerShape };
-export type UpdatePlayersAction = { type: types.UPDATE_PLAYERS, players: Map<string, PlayerShape> };
+export type SetCurrentPlayerAction = { type: types.SET_CURRENT_PLAYER, player: ApiPlayer };
+export type UpdatePlayersAction = { type: types.UPDATE_PLAYERS, players: Map<string, ApiPlayer> };
export type PlayerAction = RequestChooseUsernameAction | SetCurrentPlayerAction | UpdatePlayersAction;
@@ -18,12 +18,8 @@ export const actions = {
type: types.REQUEST_CHOOSE_USERNAME,
username,
}),
- setCurrentPlayer: (player: PlayerShape): SetCurrentPlayerAction => ({
+ setCurrentPlayer: (player: ApiPlayer): SetCurrentPlayerAction => ({
type: types.SET_CURRENT_PLAYER,
- player,
- }),
- updatePlayers: (players: Map<string, PlayerShape>): UpdatePlayersAction => ({
- type: types.UPDATE_PLAYERS,
- players,
+ player: player,
}),
};
bgstack15