import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import TrackList from '../components/TrackList' import * as spotifyActions from '../services/spotify/actions' import * as mopidyActions from '../services/mopidy/actions' class Album extends React.Component{ constructor(props) { super(props); } // on render componentDidMount(){ this.props.spotifyActions.loadAlbum( this.props.params.uri ); } // when props changed componentWillReceiveProps( nextProps ){ if( nextProps.params.uri != this.props.params.uri ){ this.props.spotifyActions.loadAlbum( nextProps.params.uri ); } } playTracks( tracks ){ var uris = []; for( var i = 0; i < tracks.length; i++ ){ uris.push( tracks[i].uri ) } this.props.mopidyActions.playTracks( uris ) } playTrack( track ){ var uris = [track.uri]; this.props.mopidyActions.playTracks( uris ) } render(){ if( this.props.spotify.album ){ return (