import React, { PropTypes } 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 * as helpers from '../../helpers' import * as uiActions from '../../services/ui/actions' import * as spotifyActions from '../../services/spotify/actions' class DiscoverCategory extends React.Component{ constructor(props){ super(props); } componentDidMount(){ this.loadCategory(); this.setWindowTitle(); } componentWillReceiveProps(nextProps){ if (nextProps.params.id != this.props.params.id){ this.loadCategory(); } 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"); } } loadCategory(){ if (!this.props.category || !this.props.category.playlists_uris){ this.props.spotifyActions.getCategory(this.props.params.id); } } loadMore(){ this.props.spotifyActions.getMore( this.props.category.playlists_more, null, { type: 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED', key: 'category:'+this.props.params.id } ); } render(){ if (helpers.isLoading(this.props.load_queue,['spotify_browse/categories/'])){ return (