import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import Header from '../../components/Header' import List from '../../components/List' import * as uiActions from '../../services/ui/actions' import * as mopidyActions from '../../services/mopidy/actions' import * as spotifyActions from '../../services/spotify/actions' class LibraryLocalArtists extends React.Component{ constructor(props) { super(props); } // on render componentDidMount(){ this.loadArtists() } componentWillReceiveProps( nextProps ){ if( !this.props.mopidy_connected && nextProps.mopidy_connected ){ this.loadArtists(nextProps); } } handleContextMenu(e,item){ var data = { e: e, context: 'artist', uris: [item.uri], item: item } this.props.uiActions.showContextMenu(data) } loadArtists(props = this.props){ if( props.mopidy_connected && !props.local_artists ){ this.props.mopidyActions.getLibraryArtists(); } } render(){ var artists = [] if (this.props.artists && this.props.local_artists){ for (var i = 0; i < this.props.local_artists.length; i++){ var uri = this.props.local_artists[i] if (this.props.artists.hasOwnProperty(uri)){ artists.push(this.props.artists[uri]) } } } return (