From 8d73d21108738754efd07b63ecc7368fd49502fa Mon Sep 17 00:00:00 2001
From: jbion <joffrey.bion@amadeus.com>
Date: Wed, 27 Feb 2019 03:12:55 +0100
Subject: Simplify state and reducers

---
 frontend/src/components/lobby/Lobby.jsx | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'frontend/src/components/lobby/Lobby.jsx')

diff --git a/frontend/src/components/lobby/Lobby.jsx b/frontend/src/components/lobby/Lobby.jsx
index f352ab83..cc979190 100644
--- a/frontend/src/components/lobby/Lobby.jsx
+++ b/frontend/src/components/lobby/Lobby.jsx
@@ -3,17 +3,17 @@ import { Button, Classes, Intent } from '@blueprintjs/core';
 import { List } from 'immutable';
 import React, { Component } from 'react';
 import { connect } from 'react-redux';
-import type { Game } from '../../models/games';
-import type { Player } from '../../models/players';
+import type { ApiLobby, ApiPlayer } from '../../api/model';
+import type { GlobalState } from '../../reducers';
 import { actions } from '../../redux/actions/lobby';
 import { getCurrentGame } from '../../redux/games';
-import { getCurrentPlayer, getPlayers } from '../../redux/players';
+import { getCurrentPlayer } from '../../redux/user';
 import { RadialPlayerList } from './RadialPlayerList';
 
 export type LobbyProps = {
-  currentGame: Game,
-  currentPlayer: Player,
-  players: List<Player>,
+  currentGame: ApiLobby,
+  currentPlayer: ApiPlayer,
+  players: List<ApiPlayer>,
   startGame: () => void,
 }
 
@@ -24,7 +24,7 @@ class LobbyPresenter extends Component<LobbyProps> {
     return (
       <div>
         <h2>{currentGame.name + ' — Lobby'}</h2>
-        <RadialPlayerList players={players} owner={currentGame.owner} currentPlayer={currentPlayer}/>
+        <RadialPlayerList players={players}/>
         {currentPlayer.gameOwner && <Button text="START" className={Classes.LARGE} intent={Intent.PRIMARY} icon='play'
                 onClick={startGame} disabled={players.size < 3}/>}
       </div>
@@ -32,13 +32,13 @@ class LobbyPresenter extends Component<LobbyProps> {
   }
 }
 
-const mapStateToProps = state => {
-  const game = getCurrentGame(state.get('games'));
+const mapStateToProps = (state: GlobalState) => {
+  const game = getCurrentGame(state);
   console.info(game);
   return {
     currentGame: game,
     currentPlayer: getCurrentPlayer(state),
-    players: game ? getPlayers(state.get('players'), game.players) : new List(),
+    players: game ? new List(game.players) : new List(),
   };
 };
 
-- 
cgit 

