2016-10-26 16:55:47 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
|
|
|
|
|
|
import Header from '../../components/Header'
|
|
|
|
|
import PlaylistGrid from '../../components/PlaylistGrid'
|
2017-05-22 04:19:44 +12:00
|
|
|
import * as helpers from '../../helpers'
|
2016-10-26 16:55:47 +13:00
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
|
|
|
|
|
|
|
|
|
class DiscoverFeatured extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// on render
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
this.props.spotifyActions.getFeaturedPlaylists();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
2017-05-22 04:19:44 +12:00
|
|
|
if (helpers.isLoading(this.props.load_queue,['spotify_browse/featured-playlists'])){
|
|
|
|
|
return (
|
|
|
|
|
<div className="view discover-featured-view">
|
|
|
|
|
<Header icon="star" title="Featured playlists" />
|
|
|
|
|
<div className="body-loader">
|
|
|
|
|
<div className="loader"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
2017-01-13 13:17:47 +13:00
|
|
|
|
|
|
|
|
var playlists = []
|
|
|
|
|
if (this.props.featured_playlists){
|
|
|
|
|
for (var i = 0; i < this.props.featured_playlists.playlists.length; i++){
|
|
|
|
|
var uri = this.props.featured_playlists.playlists[i]
|
|
|
|
|
if (this.props.playlists.hasOwnProperty(uri)){
|
|
|
|
|
playlists.push(this.props.playlists[uri])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 16:55:47 +13:00
|
|
|
return (
|
|
|
|
|
<div className="view discover-featured-view">
|
|
|
|
|
<Header icon="star" title="Featured playlists" />
|
2016-11-04 09:35:39 +13:00
|
|
|
<section className="grid-wrapper">
|
2017-01-13 13:17:47 +13:00
|
|
|
{ playlists ? <PlaylistGrid playlists={playlists} /> : null }
|
2016-11-04 09:35:39 +13:00
|
|
|
</section>
|
2016-10-26 16:55:47 +13:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2017-01-13 13:17:47 +13:00
|
|
|
return {
|
2017-05-22 04:19:44 +12:00
|
|
|
load_queue: state.ui.load_queue,
|
2017-01-13 13:17:47 +13:00
|
|
|
featured_playlists: state.spotify.featured_playlists,
|
|
|
|
|
playlists: state.ui.playlists
|
|
|
|
|
}
|
2016-10-26 16:55:47 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverFeatured)
|