summaryrefslogtreecommitdiff
path: root/frontend/src/redux
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2018-06-09 13:36:45 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2018-06-09 13:36:45 +0200
commit73389ad516af4cb49873cc19c2dc65efc77d6eb8 (patch)
tree85ecfb9b15c1db0b01300e7b18b0d7ad2d1a2d76 /frontend/src/redux
parentFix frontend gitignore (diff)
downloadseven-wonders-73389ad516af4cb49873cc19c2dc65efc77d6eb8.tar.gz
seven-wonders-73389ad516af4cb49873cc19c2dc65efc77d6eb8.tar.bz2
seven-wonders-73389ad516af4cb49873cc19c2dc65efc77d6eb8.zip
Split GameBrowser into multiple connected components
Diffstat (limited to 'frontend/src/redux')
-rw-r--r--frontend/src/redux/players.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/frontend/src/redux/players.js b/frontend/src/redux/players.js
index 1d6da562..b9f37c8c 100644
--- a/frontend/src/redux/players.js
+++ b/frontend/src/redux/players.js
@@ -39,6 +39,12 @@ export const playersReducer = (state = new PlayerState(), action: PlayerAction)
}
};
-export const getCurrentPlayer = players => players.all.get(players.current, new Player({displayName: '[ERROR]'}));
-export const getPlayer = (players, username) => players.all.get(username);
-export const getPlayers = (players, usernames) => usernames.map(u => getPlayer(players, u));
+const ANONYMOUS = new Player({displayName: '[NOT LOGGED]'});
+
+export function getCurrentPlayer(state): Player {
+ const players = state.get('players');
+ return getPlayer(players, players.current, ANONYMOUS);
+}
+
+export const getPlayer = (players, username, defaultPlayer): ?Player => players.all.get(username, defaultPlayer);
+export const getPlayers = (players, usernames): List<Player> => usernames.map(u => getPlayer(players, u, undefined));
bgstack15