import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { Link } from 'react-router' import { createStore, bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' import * as pusherActions from '../services/pusher/actions' class PusherConnectionList extends React.Component{ constructor(props) { super(props); } componentDidMount(){ if( this.props.pusher.connected ){ this.props.pusherActions.getConnectionList(); } } componentWillReceiveProps(newProps){ if( !this.props.pusher.connected && newProps.pusher.connected ){ this.props.pusherActions.getConnectionList(); } } render(){ if( !this.props.pusher.connected ) return null; if( typeof(this.props.pusher.connections) == 'undefined' || this.props.pusher.connections.length <= 0 ) return null; return (
{ this.props.pusher.connections.map( (connection, index) => { return (
{ connection.username }
{ connection.ip }
{ connection.connectionid }
); }) }
); } } const mapStateToProps = (state, ownProps) => { return state; } const mapDispatchToProps = (dispatch) => { return { pusherActions: bindActionCreators(pusherActions, dispatch) } } export default connect(mapStateToProps, mapDispatchToProps)(PusherConnectionList)