2016-10-27 10:02:12 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
2018-10-24 21:34:41 +13:00
|
|
|
import Link from '../../components/Link';
|
2016-10-27 10:02:12 +13:00
|
|
|
|
|
|
|
|
import Header from '../../components/Header'
|
2018-05-15 21:30:57 +12:00
|
|
|
import Icon from '../../components/Icon'
|
2016-10-27 10:02:12 +13:00
|
|
|
import AlbumGrid from '../../components/AlbumGrid'
|
2017-05-30 09:06:59 +12:00
|
|
|
import Parallax from '../../components/Parallax'
|
|
|
|
|
import Thumbnail from '../../components/Thumbnail'
|
|
|
|
|
import ArtistSentence from '../../components/ArtistSentence'
|
2016-11-01 08:57:28 +13:00
|
|
|
import LazyLoadListener from '../../components/LazyLoadListener'
|
2017-05-30 09:06:59 +12:00
|
|
|
|
2017-05-22 04:19:44 +12:00
|
|
|
import * as helpers from '../../helpers'
|
2016-11-01 08:57:28 +13:00
|
|
|
import * as uiActions from '../../services/ui/actions'
|
2017-05-30 09:08:40 +12:00
|
|
|
import * as mopidyActions from '../../services/mopidy/actions'
|
2016-10-27 10:02:12 +13:00
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
|
|
|
|
|
|
|
|
|
class DiscoverNewReleases extends React.Component{
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
constructor(props){
|
2016-10-27 10:02:12 +13:00
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
2018-06-29 14:26:06 +12:00
|
|
|
this.props.uiActions.setWindowTitle("New releases");
|
|
|
|
|
|
2018-04-01 21:26:42 +12:00
|
|
|
if (!this.props.new_releases){
|
|
|
|
|
this.props.spotifyActions.getNewReleases();
|
|
|
|
|
}
|
2016-10-27 10:02:12 +13:00
|
|
|
}
|
|
|
|
|
|
2016-11-01 08:57:28 +13:00
|
|
|
loadMore(){
|
2017-11-12 09:05:34 +13:00
|
|
|
this.props.spotifyActions.getMore(
|
2017-11-09 21:04:45 +13:00
|
|
|
this.props.new_releases_more,
|
|
|
|
|
null,
|
|
|
|
|
{
|
2018-09-03 14:22:27 +12:00
|
|
|
type: 'SPOTIFY_NEW_RELEASES_LOADED'
|
2017-11-09 21:04:45 +13:00
|
|
|
}
|
|
|
|
|
);
|
2016-11-01 08:57:28 +13:00
|
|
|
}
|
|
|
|
|
|
2017-05-30 09:06:59 +12:00
|
|
|
playAlbum(e,album){
|
|
|
|
|
this.props.mopidyActions.playURIs([album.uri],album.uri)
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 08:40:55 +12:00
|
|
|
handleContextMenu(e,item){
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
var data = {
|
|
|
|
|
e: e,
|
|
|
|
|
context: 'album',
|
|
|
|
|
uris: [item.uri],
|
|
|
|
|
items: [item]
|
|
|
|
|
}
|
|
|
|
|
this.props.uiActions.showContextMenu(data)
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-30 09:06:59 +12:00
|
|
|
renderIntro(album = null){
|
|
|
|
|
if (album){
|
|
|
|
|
return (
|
2018-10-24 16:56:06 +13:00
|
|
|
<div className="intro preserve-3d">
|
2018-10-23 21:54:08 +13:00
|
|
|
<Parallax image={album.images ? album.images.large : null} blur />
|
2017-05-30 09:06:59 +12:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
2018-10-24 16:56:06 +13:00
|
|
|
<div className="intro preserve-3d">
|
|
|
|
|
<Parallax />
|
2017-05-30 09:06:59 +12:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 10:02:12 +13:00
|
|
|
render(){
|
2017-05-22 04:19:44 +12:00
|
|
|
if (helpers.isLoading(this.props.load_queue,['spotify_browse/new-releases'])){
|
|
|
|
|
return (
|
|
|
|
|
<div className="view discover-new-releases-view">
|
2018-05-15 21:30:57 +12:00
|
|
|
<Header>
|
|
|
|
|
<Icon name="new_releases" type="material" />
|
|
|
|
|
New releases
|
|
|
|
|
</Header>
|
2017-08-07 21:34:33 +12:00
|
|
|
<div className="body-loader loading">
|
2017-05-22 04:19:44 +12:00
|
|
|
<div className="loader"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
2017-01-15 11:40:08 +13:00
|
|
|
|
2018-09-03 14:22:27 +12:00
|
|
|
var albums = [];
|
2017-01-15 11:40:08 +13:00
|
|
|
if (this.props.new_releases){
|
2018-09-03 14:22:27 +12:00
|
|
|
for (var uri of this.props.new_releases){
|
2017-01-15 11:40:08 +13:00
|
|
|
if (this.props.albums.hasOwnProperty(uri)){
|
2018-09-03 14:22:27 +12:00
|
|
|
albums.push(this.props.albums[uri]);
|
2017-01-15 11:40:08 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-30 09:06:59 +12:00
|
|
|
// Pull the first playlist out and we'll use this as a banner
|
2018-12-05 21:39:06 +13:00
|
|
|
var first_album = albums[0];
|
2017-05-30 09:06:59 +12:00
|
|
|
if (first_album){
|
2018-12-05 21:39:06 +13:00
|
|
|
first_album = helpers.collate(first_album, {artists: this.props.artists});
|
2017-05-30 09:06:59 +12:00
|
|
|
}
|
|
|
|
|
|
2018-07-02 16:22:05 +12:00
|
|
|
var options = (
|
2018-12-07 15:57:20 +13:00
|
|
|
<a className="button button--no-hover" onClick={e => {this.props.uiActions.hideContextMenu(); this.props.spotifyActions.getNewReleases()}}>
|
2018-07-02 16:22:05 +12:00
|
|
|
<Icon name="refresh" />Refresh
|
2018-11-16 15:26:10 +13:00
|
|
|
</a>
|
2018-07-02 16:22:05 +12:00
|
|
|
);
|
|
|
|
|
|
2016-10-27 10:02:12 +13:00
|
|
|
return (
|
2018-10-24 16:56:06 +13:00
|
|
|
<div className="view discover-new-releases-view preserve-3d">
|
2018-11-16 15:26:10 +13:00
|
|
|
<Header className="overlay" options={options} uiActions={this.props.uiActions}>
|
2018-05-15 21:30:57 +12:00
|
|
|
<Icon name="new_releases" type="material" />
|
|
|
|
|
New releases
|
|
|
|
|
</Header>
|
2017-05-30 09:06:59 +12:00
|
|
|
{this.renderIntro(first_album)}
|
2017-06-18 05:47:36 +12:00
|
|
|
<section className="content-wrapper grid-wrapper">
|
2017-01-15 11:40:08 +13:00
|
|
|
<AlbumGrid albums={albums} />
|
2016-11-04 09:35:39 +13:00
|
|
|
</section>
|
2018-09-03 08:24:49 +12:00
|
|
|
<LazyLoadListener
|
|
|
|
|
loadKey={this.props.new_releases_more}
|
|
|
|
|
showLoader={this.props.new_releases_more}
|
|
|
|
|
loadMore={() => this.loadMore()}
|
|
|
|
|
/>
|
2016-10-27 10:02:12 +13:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2017-01-15 11:40:08 +13:00
|
|
|
return {
|
2018-08-27 08:21:41 +12:00
|
|
|
theme: state.ui.theme,
|
2017-05-22 04:19:44 +12:00
|
|
|
load_queue: state.ui.load_queue,
|
2018-08-31 16:04:55 +12:00
|
|
|
artists: state.core.artists,
|
2017-08-02 10:53:30 +12:00
|
|
|
albums: state.core.albums,
|
2018-09-03 14:22:27 +12:00
|
|
|
new_releases: state.spotify.new_releases,
|
|
|
|
|
new_releases_more: state.spotify.new_releases_more,
|
|
|
|
|
new_releases_total: state.spotify.new_releases_total
|
2017-01-15 11:40:08 +13:00
|
|
|
}
|
2016-10-27 10:02:12 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
2016-11-01 08:57:28 +13:00
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
2017-05-30 09:08:40 +12:00
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
2016-10-27 10:02:12 +13:00
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverNewReleases)
|