2016-10-26 16:55:47 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
2017-05-26 09:04:58 +12:00
|
|
|
import { Link } from 'react-router'
|
2016-10-26 16:55:47 +13:00
|
|
|
|
|
|
|
|
import PlaylistGrid from '../../components/PlaylistGrid'
|
2017-05-26 09:04:58 +12:00
|
|
|
import Header from '../../components/Header'
|
2017-05-25 20:15:47 +12:00
|
|
|
import Parallax from '../../components/Parallax'
|
|
|
|
|
import Thumbnail from '../../components/Thumbnail'
|
2017-05-26 09:04:58 +12:00
|
|
|
|
2017-05-22 04:19:44 +12:00
|
|
|
import * as helpers from '../../helpers'
|
2017-05-26 09:04:58 +12:00
|
|
|
import * as mopidyActions from '../../services/mopidy/actions'
|
2016-10-26 16:55:47 +13:00
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
|
|
|
|
|
|
|
|
|
class DiscoverFeatured extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
this.props.spotifyActions.getFeaturedPlaylists();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 09:04:58 +12:00
|
|
|
playPlaylist(e,playlist){
|
|
|
|
|
this.props.mopidyActions.playPlaylist(playlist.uri)
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-25 20:15:47 +12:00
|
|
|
renderIntro(playlist = null){
|
|
|
|
|
if (playlist){
|
|
|
|
|
return (
|
|
|
|
|
<div className="intro">
|
2017-05-26 09:04:58 +12:00
|
|
|
<Parallax image={helpers.sizedImages(playlist.images).huge} blur="25"/>
|
2017-05-25 20:15:47 +12:00
|
|
|
<div className="content cf">
|
2017-05-26 09:04:58 +12:00
|
|
|
<Link to={global.baseURL+'playlist/'+playlist.uri}>
|
|
|
|
|
<Thumbnail images={playlist.images} />
|
|
|
|
|
</Link>
|
|
|
|
|
<Link to={global.baseURL+'playlist/'+playlist.uri}>
|
|
|
|
|
<h1>{playlist.name}</h1>
|
|
|
|
|
</Link>
|
|
|
|
|
{playlist.description ? <h3 dangerouslySetInnerHTML={{__html: playlist.description}}></h3> : null}
|
|
|
|
|
<div className="actions">
|
|
|
|
|
<button className="primary" onClick={e => this.playPlaylist(e,playlist)}>Play</button>
|
|
|
|
|
</div>
|
2017-05-25 20:15:47 +12:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<div className="intro">
|
|
|
|
|
<Parallax />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 16:55:47 +13:00
|
|
|
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">
|
2017-05-26 09:04:58 +12:00
|
|
|
<Header icon="star" title="Featured playlists" />
|
2017-05-22 04:19:44 +12:00
|
|
|
<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])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-25 20:15:47 +12:00
|
|
|
// Pull the first playlist out and we'll use this as a banner
|
|
|
|
|
var first_playlist = playlists.splice(0,1)
|
|
|
|
|
if (first_playlist){
|
|
|
|
|
first_playlist = first_playlist[0]
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 16:55:47 +13:00
|
|
|
return (
|
|
|
|
|
<div className="view discover-featured-view">
|
2017-05-26 09:04:58 +12:00
|
|
|
<Header className="overlay" icon="star" title="Featured playlists" />
|
2017-05-25 20:15:47 +12:00
|
|
|
{this.renderIntro(first_playlist)}
|
2016-11-04 09:35:39 +13:00
|
|
|
<section className="grid-wrapper">
|
2017-05-25 20:15:47 +12: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 {
|
2017-05-26 09:04:58 +12:00
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
2016-10-26 16:55:47 +13:00
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverFeatured)
|