diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-21 20:20:45 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-22 00:23:02 +0200 |
commit | c03e68041e0f444e18a895058afbdf0d68759517 (patch) | |
tree | 6e31f9726d36e746f43c7856cebff8c861577e31 /frontend/src/redux | |
parent | Clean name in websocket.js (diff) | |
download | seven-wonders-c03e68041e0f444e18a895058afbdf0d68759517.tar.gz seven-wonders-c03e68041e0f444e18a895058afbdf0d68759517.tar.bz2 seven-wonders-c03e68041e0f444e18a895058afbdf0d68759517.zip |
Update prettier config and reformat
Here's the discussion summary:
- single quote, because that's what I'm used to in the JS world
- trailing comma, to avoid unnecessary git changes
- print-width 120, because 120 still doesn't require to scroll horizontally, and vertical space is precious
Diffstat (limited to 'frontend/src/redux')
-rw-r--r-- | frontend/src/redux/errors.js | 19 | ||||
-rw-r--r-- | frontend/src/redux/games.js | 22 | ||||
-rw-r--r-- | frontend/src/redux/players.js | 28 |
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)); |