import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' let helpers = require('../helpers.js') import TrackList from '../components/TrackList' import Thumbnail from '../components/Thumbnail' import Dater from '../components/Dater' import LazyLoadListener from '../components/LazyLoadListener' import * as spotifyActions from '../services/spotify/actions' import * as mopidyActions from '../services/mopidy/actions' class Playlist extends React.Component{ constructor(props) { super(props); } componentDidMount(){ this.loadPlaylist(); } componentWillReceiveProps( nextProps ){ if( nextProps.params.uri != this.props.params.uri ){ this.loadPlaylist( nextProps ) }else if( !this.props.mopidy_connected && nextProps.mopidy_connected ){ if( helpers.uriSource( this.props.params.uri ) == 'm3u' ){ this.loadPlaylist( nextProps ) } } } loadPlaylist( props = this.props ){ var source = helpers.uriSource( props.params.uri ); if( source == 'spotify' ){ this.props.spotifyActions.getPlaylist( props.params.uri ); }else if( source == 'm3u' && props.mopidy_connected ){ this.props.mopidyActions.getPlaylist( props.params.uri ); } } loadMore(){ if( !this.props.playlist.tracks_more ) return this.props.spotifyActions.getURL( this.props.playlist.tracks_more, 'SPOTIFY_PLAYLIST_LOADED_MORE' ); } render(){ if( !this.props.playlist ) return null; var scheme = helpers.uriSource( this.props.params.uri ); return (