Playlists library; Local playlist loading dud tracks

This commit is contained in:
James Barnsley
2016-11-10 10:26:15 +13:00
parent 5bd6a6bbcc
commit a1bb8bf7d4
9 changed files with 70 additions and 74 deletions

View File

@ -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) => {