import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { Link } from 'react-router' import { bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' import Header from '../components/Header' import TrackList from '../components/TrackList' import ArtistGrid from '../components/ArtistGrid' import AlbumGrid from '../components/AlbumGrid' import PlaylistGrid from '../components/PlaylistGrid' import LazyLoadListener from '../components/LazyLoadListener' import * as uiActions from '../services/ui/actions' import * as mopidyActions from '../services/mopidy/actions' import * as spotifyActions from '../services/spotify/actions' class Search extends React.Component{ constructor(props) { super(props); } componentDidMount(){ this.performSearch() } componentWillReceiveProps(newProps){ // new query if( this.props.params.query != newProps.params.query ){ this.performSearch( newProps ) } // mopidy comes online if( !this.props.mopidy_connected && newProps.mopidy_connected ){ this.props.mopidyActions.getSearchResults( newProps.params.query, newProps.uri_schemes ) } } performSearch( props = this.props ){ this.props.uiActions.searchStarted() this.props.spotifyActions.getSearchResults( props.params.query ) this.props.mopidyActions.getSearchResults( props.params.query, props.uri_schemes ) } loadMore(type){ if( !this.props.search_results[type] || !this.props.search_results[type+'_more'] ){ return } this.props.spotifyActions.getURL( this.props.search_results[type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+ type.toUpperCase() ); } renderResults(){ switch( this.props.params.type ){ case 'artists': return (