import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import TrackList from '../components/TrackList' import Thumbnail from '../components/Thumbnail' import Parallax from '../components/Parallax' import ArtistSentence from '../components/ArtistSentence' import ArtistGrid from '../components/ArtistGrid' import Dater from '../components/Dater' 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.getAlbum( this.props.params.uri ); } // when props changed componentWillReceiveProps( nextProps ){ if( nextProps.params.uri != this.props.params.uri ){ this.props.spotifyActions.getAlbum( nextProps.params.uri ); } } totalTime(){ if( !this.props.spotify.album ) return null var tracks = this.props.spotify.tracks.items; var duration = 0; for( var i = 0; i < tracks.length; i++ ){ duration += tracks[i].duration_ms; } return duration; } render(){ if( this.props.spotify.album ){ var album = this.props.spotify.album; return (