Playlists library; Local playlist loading dud tracks
This commit is contained in:
@ -18,59 +18,26 @@ class LibraryPlaylists extends React.Component{
|
||||
|
||||
// on render
|
||||
componentDidMount(){
|
||||
if( this.props.mopidy.connected ){
|
||||
this.props.mopidyActions.getPlaylists();
|
||||
}
|
||||
if( this.props.spotify.authorized ){
|
||||
this.props.spotifyActions.getLibraryPlaylists();
|
||||
}
|
||||
if( this.props.mopidy_connected ) this.props.mopidyActions.getPlaylists();
|
||||
if( this.props.spotify_authorized ) this.props.spotifyActions.getAllLibraryPlaylists();
|
||||
}
|
||||
|
||||
componentWillReceiveProps( nextProps ){
|
||||
if( !this.props.mopidy.connected && nextProps.mopidy.connected ){
|
||||
this.props.mopidyActions.getPlaylists();
|
||||
}
|
||||
if( !this.props.spotify.authorized && nextProps.spotify.authorized ){
|
||||
this.props.spotifyActions.getLibraryPlaylists();
|
||||
}
|
||||
}
|
||||
|
||||
compiledPlaylistSources(){
|
||||
var playlists = [];
|
||||
|
||||
if( this.props.mopidy.playlists ){
|
||||
playlists = [...playlists, ...this.props.mopidy.playlists]
|
||||
}
|
||||
|
||||
if( this.props.spotify.library_playlists ){
|
||||
playlists = [...playlists, ...this.props.spotify.library_playlists.items]
|
||||
}
|
||||
|
||||
return playlists;
|
||||
}
|
||||
|
||||
renderPlaylists(){
|
||||
var playlists = this.compiledPlaylistSources()
|
||||
if( !playlists ) return null
|
||||
|
||||
render(){
|
||||
if( !this.props.playlists ) return null
|
||||
var columns = [
|
||||
{ name: 'name', width: '50'},
|
||||
{ name: 'uri', width: '25'}
|
||||
]
|
||||
|
||||
return <List columns={columns} rows={playlists} link_prefix="/playlist/" />
|
||||
}
|
||||
|
||||
render(){
|
||||
return (
|
||||
<div className="view library-playlists-view">
|
||||
<Header
|
||||
icon="playlist"
|
||||
title="My playlists"
|
||||
/>
|
||||
|
||||
<Header icon="playlist" title="My playlists" />
|
||||
|
||||
<section className="list-wrapper">
|
||||
{ this.renderPlaylists() }
|
||||
<List columns={columns} rows={this.props.playlists} link_prefix="/playlist/" />
|
||||
</section>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -84,7 +51,12 @@ class LibraryPlaylists extends React.Component{
|
||||
**/
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return state;
|
||||
return {
|
||||
playlists: state.ui.playlists,
|
||||
playlists_more: state.ui.playlists_more,
|
||||
mopidy_connected: state.mopidy.connected,
|
||||
spotify_authorized: state.spotify.authorized
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
|
||||
Reference in New Issue
Block a user