summaryrefslogtreecommitdiff
path: root/frontend/src/redux
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/redux')
-rw-r--r--frontend/src/redux/errors.js19
-rw-r--r--frontend/src/redux/games.js22
-rw-r--r--frontend/src/redux/players.js28
3 files changed, 32 insertions, 37 deletions
diff --git a/frontend/src/redux/errors.js b/frontend/src/redux/errors.js
index eb807fdc..ec1e30b6 100644
--- a/frontend/src/redux/errors.js
+++ b/frontend/src/redux/errors.js
@@ -1,29 +1,26 @@
-import Immutable from "seamless-immutable";
+import Immutable from 'seamless-immutable';
export const types = {
- ERROR_RECEIVED_ON_WS: "ERROR/RECEIVED_ON_WS"
+ ERROR_RECEIVED_ON_WS: 'ERROR/RECEIVED_ON_WS',
};
export const actions = {
errorReceived: error => ({
type: types.ERROR_RECEIVED_ON_WS,
- error
- })
+ error,
+ }),
};
const initialState = Immutable.from({
nextId: 0,
- history: []
+ history: [],
});
export default (state = initialState, action) => {
switch (action.type) {
case types.ERROR_RECEIVED_ON_WS:
- let error = Object.assign(
- { id: state.nextId, timestamp: new Date() },
- action.error
- );
- let newState = state.set("nextId", state.nextId + 1);
+ let error = Object.assign({ id: state.nextId, timestamp: new Date() }, action.error);
+ let newState = state.set('nextId', state.nextId + 1);
newState = addErrorToHistory(newState, error);
return newState;
default:
@@ -32,7 +29,7 @@ export default (state = initialState, action) => {
};
function addErrorToHistory(state, error) {
- return addToArray(state, "history", error);
+ return addToArray(state, 'history', error);
}
function addToArray(state, arrayKey, element) {
diff --git a/frontend/src/redux/games.js b/frontend/src/redux/games.js
index a7115dcc..9ef0e7cd 100644
--- a/frontend/src/redux/games.js
+++ b/frontend/src/redux/games.js
@@ -1,12 +1,12 @@
-import Immutable from "seamless-immutable";
+import Immutable from 'seamless-immutable';
export const types = {
- UPDATE_GAMES: "GAME/UPDATE_GAMES",
- REQUEST_CREATE_GAME: "GAME/REQUEST_CREATE_GAME",
- REQUEST_JOIN_GAME: "GAME/REQUEST_JOIN_GAME",
- REQUEST_START_GAME: "GAME/REQUEST_JOIN_GAME",
- ENTER_LOBBY: "GAME/ENTER_LOBBY",
- ENTER_GAME: "GAME/ENTER_GAME"
+ UPDATE_GAMES: 'GAME/UPDATE_GAMES',
+ REQUEST_CREATE_GAME: 'GAME/REQUEST_CREATE_GAME',
+ REQUEST_JOIN_GAME: 'GAME/REQUEST_JOIN_GAME',
+ REQUEST_START_GAME: 'GAME/REQUEST_JOIN_GAME',
+ ENTER_LOBBY: 'GAME/ENTER_LOBBY',
+ ENTER_GAME: 'GAME/ENTER_GAME',
};
export const actions = {
@@ -14,16 +14,16 @@ export const actions = {
requestJoinGame: gameId => ({ type: types.REQUEST_JOIN_GAME, gameId }),
requestCreateGame: gameName => ({
type: types.REQUEST_CREATE_GAME,
- gameName
+ gameName,
}),
requestStartGame: () => ({ type: types.REQUEST_START_GAME }),
enterLobby: lobby => ({ type: types.ENTER_LOBBY, lobby: Immutable(lobby) }),
- enterGame: () => ({ type: types.ENTER_GAME })
+ enterGame: () => ({ type: types.ENTER_GAME }),
};
const initialState = Immutable.from({
all: {},
- current: ""
+ current: '',
});
export default (state = initialState, action) => {
@@ -31,7 +31,7 @@ export default (state = initialState, action) => {
case types.UPDATE_GAMES:
return Immutable.merge(state, { all: action.games }, { deep: true });
case types.ENTER_LOBBY:
- return state.set("current", action.lobby.id);
+ return state.set('current', action.lobby.id);
default:
return state;
}
diff --git a/frontend/src/redux/players.js b/frontend/src/redux/players.js
index 4016076f..b11e920f 100644
--- a/frontend/src/redux/players.js
+++ b/frontend/src/redux/players.js
@@ -1,37 +1,37 @@
-import Immutable from "seamless-immutable";
+import Immutable from 'seamless-immutable';
export const types = {
- REQUEST_CHOOSE_USERNAME: "USER/REQUEST_CHOOSE_USERNAME",
- SET_CURRENT_PLAYER: "USER/SET_CURRENT_PLAYER",
- UPDATE_PLAYERS: "USER/UPDATE_PLAYERS"
+ REQUEST_CHOOSE_USERNAME: 'USER/REQUEST_CHOOSE_USERNAME',
+ SET_CURRENT_PLAYER: 'USER/SET_CURRENT_PLAYER',
+ UPDATE_PLAYERS: 'USER/UPDATE_PLAYERS',
};
export const actions = {
chooseUsername: username => ({
type: types.REQUEST_CHOOSE_USERNAME,
- username
+ username,
}),
setCurrentPlayer: player => ({
type: types.SET_CURRENT_PLAYER,
- player
+ player,
}),
updatePlayers: players => ({
type: types.UPDATE_PLAYERS,
- players
- })
+ players,
+ }),
};
const initialState = Immutable.from({
all: {},
- current: ""
+ current: '',
});
export default (state = initialState, action) => {
switch (action.type) {
case types.SET_CURRENT_PLAYER:
const player = action.player;
- const withNewPlayer = state.setIn(["all", player.username], player);
- return Immutable.set(withNewPlayer, "current", player.username);
+ const withNewPlayer = state.setIn(['all', player.username], player);
+ return Immutable.set(withNewPlayer, 'current', player.username);
case types.UPDATE_PLAYERS:
return Immutable.merge(state, { all: action.players }, { deep: true });
default:
@@ -39,8 +39,6 @@ export default (state = initialState, action) => {
}
};
-export const getCurrentPlayer = state =>
- state.players.all && state.players.all[state.players.current];
+export const getCurrentPlayer = state => state.players.all && state.players.all[state.players.current];
export const getPlayer = (state, username) => state.players.all[username];
-export const getPlayers = (state, usernames) =>
- usernames.map(u => getPlayer(state, u));
+export const getPlayers = (state, usernames) => usernames.map(u => getPlayer(state, u));
bgstack15