From 510c4cfeb666ab385e7200e1ac243fc6ed31043b Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Tue, 12 Jun 2018 00:36:08 +0200 Subject: Place current player always at the bottom --- frontend/src/components/lobby/RadialPlayerList.jsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/components/lobby/RadialPlayerList.jsx b/frontend/src/components/lobby/RadialPlayerList.jsx index c3dd988e..0a148c78 100644 --- a/frontend/src/components/lobby/RadialPlayerList.jsx +++ b/frontend/src/components/lobby/RadialPlayerList.jsx @@ -21,7 +21,7 @@ const PlayerItem = ({player, isOwner, isUser}) => ( ); const PlayerPlaceholder = () => ( - +
?
@@ -35,12 +35,13 @@ const UserIcon = ({isUser, isOwner}) => { }; export const RadialPlayerList = ({players, owner, currentPlayer}: RadialPlayerListProps) => { - const playerItems = players.map(player => ); + const orderedPlayers = placeFirst(players.toArray(), currentPlayer.username); + const playerItems = orderedPlayers.map(player => ); const tableImg = Round table; - return ; }; +function placeFirst(players: Array, targetFirstUsername: string): Array { + while (players[0].username !== targetFirstUsername) { + players.push(players.shift()); + } + return players; +} + function completeWithPlaceholders(playerItems: Array): Array { while (playerItems.length < 3) { playerItems.push(); -- cgit