2016-10-17 10:39:11 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
2016-10-17 14:27:48 +13:00
|
|
|
import { Link } from 'react-router'
|
2016-10-17 10:39:11 +13:00
|
|
|
|
2016-10-21 09:56:07 +13:00
|
|
|
import * as mopidyActions from '../../services/mopidy/actions'
|
|
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
2016-10-17 10:39:11 +13:00
|
|
|
|
2016-10-21 09:56:07 +13:00
|
|
|
class LibraryPlaylists extends React.Component{
|
2016-10-17 10:39:11 +13:00
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// on render
|
|
|
|
|
componentDidMount(){
|
2016-10-21 09:56:07 +13:00
|
|
|
this.props.spotifyActions.getLibraryPlaylists();
|
2016-10-17 10:39:11 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
2016-10-21 09:56:07 +13:00
|
|
|
if( this.props.spotify.libraryPlaylists ){
|
2016-10-17 14:27:48 +13:00
|
|
|
return (
|
|
|
|
|
<div>
|
2016-10-21 09:56:07 +13:00
|
|
|
<h3>My playlists</h3>
|
2016-10-17 14:27:48 +13:00
|
|
|
<ul>
|
|
|
|
|
{
|
2016-10-21 09:56:07 +13:00
|
|
|
this.props.spotify.libraryPlaylists.items.map( (playlist, index) => {
|
|
|
|
|
var link = '/playlist/' + playlist.uri;
|
|
|
|
|
return <li key={index}><Link to={link}>{ playlist.name }</Link></li>
|
2016-10-17 14:27:48 +13:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-10-17 10:39:11 +13:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-21 09:56:07 +13:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(LibraryPlaylists)
|