summaryrefslogtreecommitdiff
path: root/frontend/src/redux
diff options
context:
space:
mode:
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