2016-10-26 16:55:47 +13:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
import React 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-26 16:55:47 +13:00
|
|
|
|
2018-12-05 21:39:06 +13:00
|
|
|
import PlaylistGrid from '../../components/PlaylistGrid';
|
|
|
|
|
import Header from '../../components/Header';
|
|
|
|
|
import Icon from '../../components/Icon';
|
|
|
|
|
import Parallax from '../../components/Parallax';
|
2019-09-10 06:59:44 +12:00
|
|
|
import Loader from '../../components/Loader';
|
2017-05-26 09:04:58 +12:00
|
|
|
|
2018-12-05 21:39:06 +13:00
|
|
|
import * as helpers from '../../helpers';
|
|
|
|
|
import * as uiActions from '../../services/ui/actions';
|
|
|
|
|
import * as mopidyActions from '../../services/mopidy/actions';
|
|
|
|
|
import * as spotifyActions from '../../services/spotify/actions';
|
2016-10-26 16:55:47 +13:00
|
|
|
|
2019-09-10 06:59:44 +12:00
|
|
|
class DiscoverFeatured extends React.Component {
|
2019-09-05 15:36:11 +12:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.props.uiActions.setWindowTitle('Featured playlists');
|
|
|
|
|
if (!this.props.featured_playlists) {
|
|
|
|
|
this.props.spotifyActions.getFeaturedPlaylists();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playPlaylist(e, playlist) {
|
|
|
|
|
this.props.mopidyActions.playPlaylist(playlist.uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleContextMenu(e, item) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
const data = {
|
|
|
|
|
e,
|
|
|
|
|
context: 'playlist',
|
|
|
|
|
uris: [item.uri],
|
|
|
|
|
items: [item],
|
|
|
|
|
};
|
|
|
|
|
this.props.uiActions.showContextMenu(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderIntro(playlist = null) {
|
|
|
|
|
if (playlist) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="intro preserve-3d">
|
|
|
|
|
<Parallax image={playlist.images ? playlist.images.large : null} blur />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<div className="intro">
|
|
|
|
|
<Parallax disabled={this.props.disable_parallax} />
|
|
|
|
|
</div>
|
2019-09-10 06:59:44 +12:00
|
|
|
);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/featured-playlists'])) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="view discover-featured-view preserve-3d">
|
|
|
|
|
<Header className="overlay" uiActions={this.props.uiActions}>
|
|
|
|
|
<Icon name="star" type="material" />
|
2018-05-15 21:30:57 +12:00
|
|
|
Featured playlists
|
2019-09-05 15:36:11 +12:00
|
|
|
</Header>
|
2019-09-10 06:59:44 +12:00
|
|
|
<Loader body loading />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const playlists = [];
|
|
|
|
|
if (this.props.featured_playlists) {
|
|
|
|
|
for (let i = 0; i < this.props.featured_playlists.playlists.length; i++) {
|
|
|
|
|
const uri = this.props.featured_playlists.playlists[i];
|
|
|
|
|
if (this.props.playlists.hasOwnProperty(uri)) {
|
|
|
|
|
playlists.push(this.props.playlists[uri]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Pull the first playlist out and we'll use this for the parallax artwork
|
|
|
|
|
const first_playlist = playlists[0];
|
|
|
|
|
|
|
|
|
|
const options = (
|
|
|
|
|
<a className="button button--no-hover" onClick={(e) => { this.props.uiActions.hideContextMenu(); this.props.spotifyActions.getFeaturedPlaylists(); }}>
|
2019-09-10 06:59:44 +12:00
|
|
|
<Icon name="refresh" />
|
2019-09-05 15:36:11 +12:00
|
|
|
Refresh
|
|
|
|
|
</a>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="view discover-featured-view preserve-3d">
|
|
|
|
|
<Header className="overlay" options={options}>
|
|
|
|
|
<Icon name="star" type="material" />
|
2018-05-15 21:30:57 +12:00
|
|
|
Featured playlists
|
2019-09-05 15:36:11 +12:00
|
|
|
</Header>
|
|
|
|
|
{this.renderIntro(first_playlist)}
|
|
|
|
|
<section className="content-wrapper grid-wrapper">
|
|
|
|
|
{playlists ? <PlaylistGrid playlists={playlists} /> : null }
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-10-26 16:55:47 +13:00
|
|
|
}
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const mapStateToProps = (state, ownProps) => ({
|
|
|
|
|
theme: state.ui.theme,
|
|
|
|
|
load_queue: state.ui.load_queue,
|
|
|
|
|
featured_playlists: state.spotify.featured_playlists,
|
|
|
|
|
playlists: state.core.playlists,
|
|
|
|
|
});
|
2016-10-26 16:55:47 +13:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
|
|
|
|
});
|
2016-10-26 16:55:47 +13:00
|
|
|
|
2019-09-10 06:59:44 +12:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverFeatured);
|