From 8d73d21108738754efd07b63ecc7368fd49502fa Mon Sep 17 00:00:00 2001 From: jbion 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, + currentGame: ApiLobby, + currentPlayer: ApiPlayer, + players: List, startGame: () => void, } @@ -24,7 +24,7 @@ class LobbyPresenter extends Component { return (

{currentGame.name + ' — Lobby'}

- + {currentPlayer.gameOwner &&
@@ -32,13 +32,13 @@ class LobbyPresenter extends Component { } } -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