Auto eslint fix
This commit is contained in:
@ -1,67 +1,65 @@
|
||||
|
||||
import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
|
||||
import Header from '../../components/Header'
|
||||
import Icon from '../../components/Icon'
|
||||
import CategoryGrid from '../../components/CategoryGrid'
|
||||
import Header from '../../components/Header';
|
||||
import Icon from '../../components/Icon';
|
||||
import CategoryGrid from '../../components/CategoryGrid';
|
||||
|
||||
import * as helpers from '../../helpers'
|
||||
import * as uiActions from '../../services/ui/actions'
|
||||
import * as spotifyActions from '../../services/spotify/actions'
|
||||
import * as helpers from '../../helpers';
|
||||
import * as uiActions from '../../services/ui/actions';
|
||||
import * as spotifyActions from '../../services/spotify/actions';
|
||||
|
||||
class DiscoverCategories extends React.Component{
|
||||
class DiscoverCategories extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
componentDidMount() {
|
||||
// Check for an empty category index, or where we've only got one loaded
|
||||
// This would be the case if you've refreshed from within a category and only loaded
|
||||
// the single record.
|
||||
if (!this.props.categories || Object.keys(this.props.categories).length <= 1) {
|
||||
this.props.spotifyActions.getCategories();
|
||||
}
|
||||
this.props.uiActions.setWindowTitle('Genre / Mood');
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
render() {
|
||||
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/categories'])) {
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header icon="grid" title="Genre / Mood" />
|
||||
<div className="body-loader loading">
|
||||
<div className="loader" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Check for an empty category index, or where we've only got one loaded
|
||||
// This would be the case if you've refreshed from within a category and only loaded
|
||||
// the single record.
|
||||
if (!this.props.categories || Object.keys(this.props.categories).length <= 1){
|
||||
this.props.spotifyActions.getCategories();
|
||||
}
|
||||
this.props.uiActions.setWindowTitle("Genre / Mood");
|
||||
}
|
||||
// convert categories object into simple array
|
||||
const categories = [];
|
||||
if (this.props.categories) {
|
||||
for (const key in this.props.categories) {
|
||||
if (this.props.categories.hasOwnProperty(key)) {
|
||||
categories.push(this.props.categories[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
if (helpers.isLoading(this.props.load_queue,['spotify_browse/categories'])){
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header icon="grid" title="Genre / Mood" />
|
||||
<div className="body-loader loading">
|
||||
<div className="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// convert categories object into simple array
|
||||
var categories = []
|
||||
if (this.props.categories){
|
||||
for (var key in this.props.categories){
|
||||
if (this.props.categories.hasOwnProperty(key)){
|
||||
categories.push(this.props.categories[key])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header uiActions={this.props.uiActions}>
|
||||
<Icon name="mood" type="material" />
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header uiActions={this.props.uiActions}>
|
||||
<Icon name="mood" type="material" />
|
||||
Genre / Mood
|
||||
</Header>
|
||||
<section className="content-wrapper grid-wrapper">
|
||||
<CategoryGrid categories={categories} />
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</Header>
|
||||
<section className="content-wrapper grid-wrapper">
|
||||
<CategoryGrid categories={categories} />
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,20 +67,16 @@ class DiscoverCategories extends React.Component{
|
||||
* Export our component
|
||||
*
|
||||
* We also integrate our global store, using connect()
|
||||
**/
|
||||
* */
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
categories: state.spotify.categories,
|
||||
load_queue: state.ui.load_queue
|
||||
}
|
||||
}
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
categories: state.spotify.categories,
|
||||
load_queue: state.ui.load_queue,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverCategories)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverCategories);
|
||||
|
||||
@ -1,122 +1,117 @@
|
||||
|
||||
import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
|
||||
import Header from '../../components/Header'
|
||||
import Icon from '../../components/Icon'
|
||||
import PlaylistGrid from '../../components/PlaylistGrid'
|
||||
import LazyLoadListener from '../../components/LazyLoadListener'
|
||||
import Header from '../../components/Header';
|
||||
import Icon from '../../components/Icon';
|
||||
import PlaylistGrid from '../../components/PlaylistGrid';
|
||||
import LazyLoadListener from '../../components/LazyLoadListener';
|
||||
|
||||
import * as helpers from '../../helpers'
|
||||
import * as uiActions from '../../services/ui/actions'
|
||||
import * as spotifyActions from '../../services/spotify/actions'
|
||||
import * as helpers from '../../helpers';
|
||||
import * as uiActions from '../../services/ui/actions';
|
||||
import * as spotifyActions from '../../services/spotify/actions';
|
||||
|
||||
class DiscoverCategory extends React.Component{
|
||||
class DiscoverCategory extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.loadCategory();
|
||||
this.setWindowTitle();
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
this.loadCategory();
|
||||
this.setWindowTitle();
|
||||
}
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.match.params.id != this.props.match.params.id) {
|
||||
this.loadCategory();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
if (nextProps.match.params.id != this.props.match.params.id){
|
||||
this.loadCategory();
|
||||
}
|
||||
if (!this.props.category && nextProps.category) {
|
||||
this.setWindowTitle(nextProps.category);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.props.category && nextProps.category){
|
||||
this.setWindowTitle(nextProps.category);
|
||||
}
|
||||
}
|
||||
setWindowTitle(category = this.props.category) {
|
||||
if (category) {
|
||||
this.props.uiActions.setWindowTitle(category.name);
|
||||
} else {
|
||||
this.props.uiActions.setWindowTitle('Genre / Mood');
|
||||
}
|
||||
}
|
||||
|
||||
setWindowTitle(category = this.props.category){
|
||||
if (category){
|
||||
this.props.uiActions.setWindowTitle(category.name);
|
||||
} else{
|
||||
this.props.uiActions.setWindowTitle("Genre / Mood");
|
||||
}
|
||||
}
|
||||
loadCategory() {
|
||||
if (!this.props.category) {
|
||||
this.props.spotifyActions.getCategory(this.props.match.params.id);
|
||||
}
|
||||
|
||||
loadCategory(){
|
||||
if (!this.props.category){
|
||||
this.props.spotifyActions.getCategory(this.props.match.params.id);
|
||||
}
|
||||
if (!this.props.category.playlists_uris) {
|
||||
this.props.spotifyActions.getCategoryPlaylists(this.props.match.params.id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.props.category.playlists_uris){
|
||||
this.props.spotifyActions.getCategoryPlaylists(this.props.match.params.id);
|
||||
}
|
||||
}
|
||||
loadMore() {
|
||||
this.props.spotifyActions.getMore(
|
||||
this.props.category.playlists_more,
|
||||
null,
|
||||
{
|
||||
type: 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED_MORE',
|
||||
uri: `category:${this.props.match.params.id}`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
this.props.spotifyActions.getMore(
|
||||
this.props.category.playlists_more,
|
||||
null,
|
||||
{
|
||||
type: 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED_MORE',
|
||||
uri: 'category:'+this.props.match.params.id
|
||||
}
|
||||
);
|
||||
}
|
||||
render() {
|
||||
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/categories/'])) {
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header>
|
||||
<Icon name="mood" type="material" />
|
||||
{(this.props.category ? this.props.category.name : 'Category')}
|
||||
</Header>
|
||||
<div className="body-loader loading">
|
||||
<div className="loader" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
render(){
|
||||
if (helpers.isLoading(this.props.load_queue,['spotify_browse/categories/'])){
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header>
|
||||
<Icon name="mood" type="material" />
|
||||
{(this.props.category ? this.props.category.name : 'Category')}
|
||||
</Header>
|
||||
<div className="body-loader loading">
|
||||
<div className="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (!this.props.category) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.props.category){
|
||||
return null;
|
||||
}
|
||||
const category = helpers.collate(this.props.category, { playlists: this.props.playlists });
|
||||
|
||||
var category = helpers.collate(this.props.category, {playlists: this.props.playlists});
|
||||
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header uiActions={this.props.uiActions}>
|
||||
<Icon name="mood" type="material" />
|
||||
{category.name}
|
||||
</Header>
|
||||
<div className="content-wrapper">
|
||||
<section className="grid-wrapper">
|
||||
<PlaylistGrid playlists={category.playlists} />
|
||||
</section>
|
||||
<LazyLoadListener
|
||||
loadKey={category.playlists_more}
|
||||
showLoader={category.playlists_more}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="view discover-categories-view">
|
||||
<Header uiActions={this.props.uiActions}>
|
||||
<Icon name="mood" type="material" />
|
||||
{category.name}
|
||||
</Header>
|
||||
<div className="content-wrapper">
|
||||
<section className="grid-wrapper">
|
||||
<PlaylistGrid playlists={category.playlists} />
|
||||
</section>
|
||||
<LazyLoadListener
|
||||
loadKey={category.playlists_more}
|
||||
showLoader={category.playlists_more}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
load_queue: state.ui.load_queue,
|
||||
playlists: state.core.playlists,
|
||||
category: (state.spotify.categories && state.spotify.categories['category:'+ownProps.match.params.id] !== undefined ? state.spotify.categories['category:'+ownProps.match.params.id] : false )
|
||||
}
|
||||
}
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
load_queue: state.ui.load_queue,
|
||||
playlists: state.core.playlists,
|
||||
category: (state.spotify.categories && state.spotify.categories[`category:${ownProps.match.params.id}`] !== undefined ? state.spotify.categories[`category:${ownProps.match.params.id}`] : false),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverCategory)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverCategory);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import Link from '../../components/Link';
|
||||
|
||||
import PlaylistGrid from '../../components/PlaylistGrid';
|
||||
@ -17,114 +17,109 @@ import * as uiActions from '../../services/ui/actions';
|
||||
import * as mopidyActions from '../../services/mopidy/actions';
|
||||
import * as spotifyActions from '../../services/spotify/actions';
|
||||
|
||||
class DiscoverFeatured extends React.Component{
|
||||
class DiscoverFeatured extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.uiActions.setWindowTitle('Featured playlists');
|
||||
if (!this.props.featured_playlists) {
|
||||
this.props.spotifyActions.getFeaturedPlaylists();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
handleContextMenu(e,item){
|
||||
e.preventDefault()
|
||||
var data = {
|
||||
e: 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>
|
||||
);
|
||||
}
|
||||
|
||||
renderIntro(playlist = null){
|
||||
if (playlist){
|
||||
return (
|
||||
<div className="intro preserve-3d">
|
||||
<Parallax image={playlist.images ? playlist.images.large : null} blur />
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div className="intro">
|
||||
<Parallax disabled={this.props.disable_parallax} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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" />
|
||||
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" />
|
||||
Featured playlists
|
||||
</Header>
|
||||
<div className="body-loader loading">
|
||||
<div className="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</Header>
|
||||
<div className="body-loader loading">
|
||||
<div className="loader" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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])
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
var first_playlist = playlists[0];
|
||||
// Pull the first playlist out and we'll use this for the parallax artwork
|
||||
const first_playlist = playlists[0];
|
||||
|
||||
var options = (
|
||||
<a className="button button--no-hover" onClick={e => {this.props.uiActions.hideContextMenu(); this.props.spotifyActions.getFeaturedPlaylists()}}>
|
||||
<Icon name="refresh" />Refresh
|
||||
</a>
|
||||
);
|
||||
const options = (
|
||||
<a className="button button--no-hover" onClick={(e) => { this.props.uiActions.hideContextMenu(); this.props.spotifyActions.getFeaturedPlaylists(); }}>
|
||||
<Icon name="refresh" />
|
||||
Refresh
|
||||
</a>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="view discover-featured-view preserve-3d">
|
||||
<Header className="overlay" options={options}>
|
||||
<Icon name="star" type="material" />
|
||||
return (
|
||||
<div className="view discover-featured-view preserve-3d">
|
||||
<Header className="overlay" options={options}>
|
||||
<Icon name="star" type="material" />
|
||||
Featured playlists
|
||||
</Header>
|
||||
{this.renderIntro(first_playlist)}
|
||||
<section className="content-wrapper grid-wrapper">
|
||||
{playlists ? <PlaylistGrid playlists={playlists} /> : null }
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</Header>
|
||||
{this.renderIntro(first_playlist)}
|
||||
<section className="content-wrapper grid-wrapper">
|
||||
{playlists ? <PlaylistGrid playlists={playlists} /> : null }
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
theme: state.ui.theme,
|
||||
load_queue: state.ui.load_queue,
|
||||
featured_playlists: state.spotify.featured_playlists,
|
||||
playlists: state.core.playlists
|
||||
}
|
||||
}
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
theme: state.ui.theme,
|
||||
load_queue: state.ui.load_queue,
|
||||
featured_playlists: state.spotify.featured_playlists,
|
||||
playlists: state.core.playlists,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverFeatured)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverFeatured);
|
||||
|
||||
@ -17,135 +17,130 @@ import * as uiActions from '../../services/ui/actions';
|
||||
import * as mopidyActions from '../../services/mopidy/actions';
|
||||
import * as spotifyActions from '../../services/spotify/actions';
|
||||
|
||||
class DiscoverNewReleases extends React.Component{
|
||||
class DiscoverNewReleases extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.uiActions.setWindowTitle('New releases');
|
||||
|
||||
componentDidMount(){
|
||||
this.props.uiActions.setWindowTitle("New releases");
|
||||
if (!this.props.new_releases) {
|
||||
this.props.spotifyActions.getNewReleases();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.props.new_releases){
|
||||
this.props.spotifyActions.getNewReleases();
|
||||
}
|
||||
}
|
||||
loadMore() {
|
||||
this.props.spotifyActions.getMore(
|
||||
this.props.new_releases_more,
|
||||
null,
|
||||
{
|
||||
type: 'SPOTIFY_NEW_RELEASES_LOADED',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
this.props.spotifyActions.getMore(
|
||||
this.props.new_releases_more,
|
||||
null,
|
||||
{
|
||||
type: 'SPOTIFY_NEW_RELEASES_LOADED'
|
||||
}
|
||||
);
|
||||
}
|
||||
playAlbum(e, album) {
|
||||
this.props.mopidyActions.playURIs([album.uri], album.uri);
|
||||
}
|
||||
|
||||
playAlbum(e,album){
|
||||
this.props.mopidyActions.playURIs([album.uri],album.uri)
|
||||
}
|
||||
handleContextMenu(e, item) {
|
||||
e.preventDefault();
|
||||
const data = {
|
||||
e,
|
||||
context: 'album',
|
||||
uris: [item.uri],
|
||||
items: [item],
|
||||
};
|
||||
this.props.uiActions.showContextMenu(data);
|
||||
}
|
||||
|
||||
handleContextMenu(e,item){
|
||||
e.preventDefault()
|
||||
var data = {
|
||||
e: e,
|
||||
context: 'album',
|
||||
uris: [item.uri],
|
||||
items: [item]
|
||||
}
|
||||
this.props.uiActions.showContextMenu(data)
|
||||
}
|
||||
renderIntro(album = null) {
|
||||
if (album) {
|
||||
return (
|
||||
<div className="intro preserve-3d">
|
||||
<Parallax image={album.images ? album.images.large : null} blur />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="intro preserve-3d">
|
||||
<Parallax />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderIntro(album = null){
|
||||
if (album){
|
||||
return (
|
||||
<div className="intro preserve-3d">
|
||||
<Parallax image={album.images ? album.images.large : null} blur />
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div className="intro preserve-3d">
|
||||
<Parallax />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
if (helpers.isLoading(this.props.load_queue,['spotify_browse/new-releases'])){
|
||||
return (
|
||||
<div className="view discover-new-releases-view">
|
||||
<Header>
|
||||
<Icon name="new_releases" type="material" />
|
||||
render() {
|
||||
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/new-releases'])) {
|
||||
return (
|
||||
<div className="view discover-new-releases-view">
|
||||
<Header>
|
||||
<Icon name="new_releases" type="material" />
|
||||
New releases
|
||||
</Header>
|
||||
<div className="body-loader loading">
|
||||
<div className="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</Header>
|
||||
<div className="body-loader loading">
|
||||
<div className="loader" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
var albums = [];
|
||||
if (this.props.new_releases){
|
||||
for (var uri of this.props.new_releases){
|
||||
if (this.props.albums.hasOwnProperty(uri)){
|
||||
albums.push(this.props.albums[uri]);
|
||||
}
|
||||
}
|
||||
}
|
||||
const albums = [];
|
||||
if (this.props.new_releases) {
|
||||
for (const uri of this.props.new_releases) {
|
||||
if (this.props.albums.hasOwnProperty(uri)) {
|
||||
albums.push(this.props.albums[uri]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pull the first playlist out and we'll use this as a banner
|
||||
var first_album = albums[0];
|
||||
if (first_album){
|
||||
first_album = helpers.collate(first_album, {artists: this.props.artists});
|
||||
}
|
||||
// Pull the first playlist out and we'll use this as a banner
|
||||
let first_album = albums[0];
|
||||
if (first_album) {
|
||||
first_album = helpers.collate(first_album, { artists: this.props.artists });
|
||||
}
|
||||
|
||||
var options = (
|
||||
<a className="button button--no-hover" onClick={e => {this.props.uiActions.hideContextMenu(); this.props.spotifyActions.getNewReleases()}}>
|
||||
<Icon name="refresh" />Refresh
|
||||
</a>
|
||||
);
|
||||
const options = (
|
||||
<a className="button button--no-hover" onClick={(e) => { this.props.uiActions.hideContextMenu(); this.props.spotifyActions.getNewReleases(); }}>
|
||||
<Icon name="refresh" />
|
||||
Refresh
|
||||
</a>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="view discover-new-releases-view preserve-3d">
|
||||
<Header className="overlay" options={options} uiActions={this.props.uiActions}>
|
||||
<Icon name="new_releases" type="material" />
|
||||
return (
|
||||
<div className="view discover-new-releases-view preserve-3d">
|
||||
<Header className="overlay" options={options} uiActions={this.props.uiActions}>
|
||||
<Icon name="new_releases" type="material" />
|
||||
New releases
|
||||
</Header>
|
||||
{this.renderIntro(first_album)}
|
||||
<section className="content-wrapper grid-wrapper">
|
||||
<AlbumGrid albums={albums} />
|
||||
</section>
|
||||
<LazyLoadListener
|
||||
loadKey={this.props.new_releases_more}
|
||||
showLoader={this.props.new_releases_more}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</Header>
|
||||
{this.renderIntro(first_album)}
|
||||
<section className="content-wrapper grid-wrapper">
|
||||
<AlbumGrid albums={albums} />
|
||||
</section>
|
||||
<LazyLoadListener
|
||||
loadKey={this.props.new_releases_more}
|
||||
showLoader={this.props.new_releases_more}
|
||||
loadMore={() => this.loadMore()}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
theme: state.ui.theme,
|
||||
load_queue: state.ui.load_queue,
|
||||
artists: state.core.artists,
|
||||
albums: state.core.albums,
|
||||
new_releases: (state.spotify.new_releases ? state.spotify.new_releases : null),
|
||||
new_releases_more: (state.spotify.new_releases_more ? state.spotify.new_releases_more : null),
|
||||
new_releases_total: (state.spotify.new_releases_total ? state.spotify.new_releases_total : null)
|
||||
}
|
||||
}
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
theme: state.ui.theme,
|
||||
load_queue: state.ui.load_queue,
|
||||
artists: state.core.artists,
|
||||
albums: state.core.albums,
|
||||
new_releases: (state.spotify.new_releases ? state.spotify.new_releases : null),
|
||||
new_releases_more: (state.spotify.new_releases_more ? state.spotify.new_releases_more : null),
|
||||
new_releases_total: (state.spotify.new_releases_total ? state.spotify.new_releases_total : null),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverNewReleases)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DiscoverNewReleases);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user