Files
Iris/src/components/Queue.js

63 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-10-03 14:44:27 +13:00
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Services from '../services/Services'
2016-10-03 15:22:15 +13:00
import TrackList from '../components/TrackList'
import * as queueActions from '../actions/queueActions'
2016-10-03 14:44:27 +13:00
class NowPlaying extends React.Component{
constructor(props) {
super(props);
this.state = {
tracks: []
}
}
// on render
componentDidMount(){
Services.get('services.mopidy')
.then( function(MopidyService){
MopidyService.getCurrentTracklist();
2016-10-03 14:44:27 +13:00
})
}
renderTracks(){
if( this.state.tracks ){
return (
2016-10-03 15:22:15 +13:00
<TrackList tracks={this.state.tracks} />
2016-10-03 14:44:27 +13:00
);
}
return null;
}
render(){
return (
<div>
<h3>Now playing</h3>
{ this.renderTracks() }
</div>
);
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
2016-10-03 15:22:15 +13:00
queueActions: bindActionCreators(queueActions, dispatch)
2016-10-03 14:44:27 +13:00
}
}
export default connect(mapStateToProps, mapDispatchToProps)(NowPlaying)