import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import { Link } from 'react-router' import LazyLoadListener from '../components/LazyLoadListener' import Header from '../components/Header' import TrackList from '../components/TrackList' import AlbumGrid from '../components/AlbumGrid' import Thumbnail from '../components/Thumbnail' import Parallax from '../components/Parallax' import ArtistGrid from '../components/ArtistGrid' import RelatedArtists from '../components/RelatedArtists' import FollowButton from '../components/Fields/FollowButton' import ContextMenuTrigger from '../components/ContextMenuTrigger' import DropdownField from '../components/Fields/DropdownField' import Icon from '../components/Icon' import * as helpers from '../helpers' import * as uiActions from '../services/ui/actions' import * as mopidyActions from '../services/mopidy/actions' import * as pusherActions from '../services/pusher/actions' import * as lastfmActions from '../services/lastfm/actions' import * as spotifyActions from '../services/spotify/actions' class Artist extends React.Component{ constructor(props){ super(props) } componentDidMount(){ this.loadArtist(); } componentWillReceiveProps(nextProps){ if (nextProps.params.uri != this.props.params.uri){ this.loadArtist(nextProps); }else if (!this.props.mopidy_connected && nextProps.mopidy_connected){ if (helpers.uriSource(this.props.params.uri ) != 'spotify'){ this.loadArtist(nextProps); } } } handleContextMenu(e){ var data = { e: e, context: 'artist', items: [this.props.artist], uris: [this.props.params.uri] } this.props.uiActions.showContextMenu(data); } loadArtist(props = this.props){ switch(helpers.uriSource(props.params.uri )){ case 'spotify': if (props.artist && props.artist.albums_uris && props.artist.related_artists_uris){ console.info('Loading spotify artist from index'); } else { this.props.spotifyActions.getArtist(props.params.uri, true); } this.props.spotifyActions.following(props.params.uri); break default: if (props.mopidy_connected){ if (props.artist && props.artist.images && props.artist.albums_uris){ console.info('Loading local artist from index'); } else { this.props.mopidyActions.getArtist(props.params.uri); } } break } } loadMore(){ this.props.spotifyActions.getMore( this.props.artist.albums_more, { parent_type: 'artist', parent_key: this.props.params.uri, records_type: 'album' } ); } inLibrary(){ var library = helpers.uriSource(this.props.params.uri)+'_library_artists' return (this.props[library] && this.props[library].indexOf(this.props.params.uri) > -1) } setSort(value){ var reverse = false if (this.props.sort == value ) reverse = !this.props.sort_reverse var data = { artist_albums_sort_reverse: reverse, artist_albums_sort: value } this.props.uiActions.set(data) } setFilter(value){ this.props.uiActions.set({artist_albums_filter: value}); } renderSubViewMenu(){ return (
{this.props.artist.bio.content}