|
|
|
|
@ -30,8 +30,8 @@ class Search extends React.Component{
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
|
|
|
|
|
// Make sure we have search parameters to start with
|
|
|
|
|
if (this.props.params && this.props.params.type && this.props.params.query){
|
|
|
|
|
this.props.coreActions.startSearch(this.props.params.type, this.props.params.query)
|
|
|
|
|
if (this.props.params && this.props.params.query){
|
|
|
|
|
this.props.coreActions.startSearch(this.props.view, this.props.params.query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Auto-focus on the input field
|
|
|
|
|
@ -41,21 +41,21 @@ class Search extends React.Component{
|
|
|
|
|
componentWillReceiveProps(newProps){
|
|
|
|
|
|
|
|
|
|
// Make sure we have some search parameters
|
|
|
|
|
if (newProps.params && newProps.params.type && newProps.params.query){
|
|
|
|
|
if (newProps.params && newProps.view && newProps.params.query){
|
|
|
|
|
|
|
|
|
|
if (this.props.params.query != newProps.params.query || this.props.params.type != newProps.params.type){
|
|
|
|
|
this.props.coreActions.startSearch(newProps.params.type, newProps.params.query)
|
|
|
|
|
if (this.props.params.query != newProps.params.query || this.props.view != newProps.view){
|
|
|
|
|
this.props.coreActions.startSearch(newProps.view, newProps.params.query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mopidy comes online
|
|
|
|
|
if (!this.props.mopidy_connected && newProps.mopidy_connected){
|
|
|
|
|
this.props.coreActions.startSearch(newProps.params.type, newProps.params.query, true)
|
|
|
|
|
this.props.coreActions.startSearch(newProps.view, newProps.params.query, true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadMore(type){
|
|
|
|
|
this.props.spotifyActions.getURL( this.props[type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+type.toUpperCase());
|
|
|
|
|
this.props.spotifyActions.getURL( this.props['spotify_'+type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+type.toUpperCase());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderResults(){
|
|
|
|
|
@ -93,7 +93,7 @@ class Search extends React.Component{
|
|
|
|
|
tracks = [...tracks, ...this.props.mopidy_search_results.tracks]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (this.props.params.type){
|
|
|
|
|
switch (this.props.view){
|
|
|
|
|
|
|
|
|
|
case 'artists':
|
|
|
|
|
return (
|
|
|
|
|
@ -132,7 +132,7 @@ class Search extends React.Component{
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<section className="list-wrapper">
|
|
|
|
|
<TrackList tracks={tracks} uri={'iris:search:'+this.props.params.type+':'+this.props.params.query} show_source_icon />
|
|
|
|
|
<TrackList tracks={tracks} uri={'iris:search:'+this.props.params.query} show_source_icon />
|
|
|
|
|
<LazyLoadListener enabled={this.props['tracks_more'] && spotify_search_enabled} loadMore={ () => this.loadMore('tracks') }/>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
@ -145,7 +145,7 @@ class Search extends React.Component{
|
|
|
|
|
var artists_section = (
|
|
|
|
|
<section>
|
|
|
|
|
<div className="inner">
|
|
|
|
|
<h4><Link to={global.baseURL+'search/iris:search:artists:'+this.props.params.query}>Artists</Link></h4>
|
|
|
|
|
<h4>Artists</h4>
|
|
|
|
|
<ArtistGrid show_source_icon artists={artists.slice(0,5)} />
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
@ -158,7 +158,7 @@ class Search extends React.Component{
|
|
|
|
|
var albums_section = (
|
|
|
|
|
<section>
|
|
|
|
|
<div className="inner">
|
|
|
|
|
<h4><Link to={global.baseURL+'search/iris:search:albums:'+this.props.params.query}>Albums</Link></h4>
|
|
|
|
|
<h4>Albums</h4>
|
|
|
|
|
<AlbumGrid show_source_icon albums={albums.slice(0,5)} />
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
@ -171,7 +171,7 @@ class Search extends React.Component{
|
|
|
|
|
var playlists_section = (
|
|
|
|
|
<section>
|
|
|
|
|
<div className="inner">
|
|
|
|
|
<h4><Link to={global.baseURL+'search/iris:search:playlists:'+this.props.params.query}>Playlists</Link></h4>
|
|
|
|
|
<h4>Playlists</h4>
|
|
|
|
|
<PlaylistGrid show_source_icon playlists={playlists.slice(0,5)} />
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
@ -189,8 +189,8 @@ class Search extends React.Component{
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<section className="list-wrapper">
|
|
|
|
|
<h4><Link to={global.baseURL+'search/'+this.props.params.query+'/tracks'}>Tracks</Link></h4>
|
|
|
|
|
<TrackList tracks={tracks} uri={'iris:search:'+this.props.params.type+':'+this.props.params.query} show_source_icon />
|
|
|
|
|
<h4>Tracks</h4>
|
|
|
|
|
<TrackList tracks={tracks} uri={'iris:search:'+this.props.params.query} show_source_icon />
|
|
|
|
|
<LazyLoadListener loading={this.props['tracks_more'] && spotify_search_enabled} loadMore={ () => this.loadMore('tracks') }/>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
@ -199,13 +199,8 @@ class Search extends React.Component{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleTypeChange(val){
|
|
|
|
|
this.props.uiActions.hideContextMenu()
|
|
|
|
|
hashHistory.push(global.baseURL+'search/iris:search:'+val+':'+this.props.params.query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
var type_options = [
|
|
|
|
|
var view_options = [
|
|
|
|
|
{
|
|
|
|
|
value: 'all',
|
|
|
|
|
label: 'All'
|
|
|
|
|
@ -230,8 +225,8 @@ class Search extends React.Component{
|
|
|
|
|
|
|
|
|
|
var options = (
|
|
|
|
|
<span>
|
|
|
|
|
<DropdownField icon="eye" name="Type" value={this.props.params.type} options={type_options} handleChange={val => this.handleTypeChange(val)} />
|
|
|
|
|
<button className="no-hover" onClick={e => this.props.uiActions.openModal('search_settings', {type: this.props.params.type, query: this.props.params.query})}>
|
|
|
|
|
<DropdownField icon="eye" name="View" value={this.props.view} options={view_options} handleChange={val => {this.props.uiActions.set({ search_view: val }); this.props.uiActions.hideContextMenu() }} />
|
|
|
|
|
<button className="no-hover" onClick={e => this.props.uiActions.openModal('search_settings', {query: this.props.params.query})}>
|
|
|
|
|
<FontAwesome name="wrench" />
|
|
|
|
|
Sources
|
|
|
|
|
</button>
|
|
|
|
|
@ -252,6 +247,7 @@ class Search extends React.Component{
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {
|
|
|
|
|
view: (state.ui.search_view ? state.ui.search_view : 'all'),
|
|
|
|
|
mopidy_connected: state.mopidy.connected,
|
|
|
|
|
spotify_connected: state.spotify.connected,
|
|
|
|
|
albums: (state.core.albums ? state.core.albums : []),
|
|
|
|
|
|