Search
This commit is contained in:
@ -13,6 +13,7 @@ import ArtistGrid from '../components/ArtistGrid'
|
||||
import AlbumGrid from '../components/AlbumGrid'
|
||||
import PlaylistGrid from '../components/PlaylistGrid'
|
||||
import LazyLoadListener from '../components/LazyLoadListener'
|
||||
import SearchForm from '../components/SearchForm'
|
||||
|
||||
import * as helpers from '../helpers'
|
||||
import * as uiActions from '../services/ui/actions'
|
||||
@ -26,18 +27,26 @@ class Search extends React.Component{
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
this.props.uiActions.startSearch(this.props.params.type, this.props.params.query)
|
||||
|
||||
// Make sure we have search parameters to start with
|
||||
if (this.props.params && this.props.params.type && this.props.params.query){
|
||||
this.props.uiActions.startSearch(this.props.params.type, this.props.params.query)
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps){
|
||||
|
||||
// Make sure we have some search parameters
|
||||
if (newProps.params && newProps.params.type && newProps.params.query){
|
||||
|
||||
if (this.props.params.query != newProps.params.query || this.props.params.type != newProps.params.type){
|
||||
this.props.uiActions.startSearch(newProps.params.type, newProps.params.query)
|
||||
}
|
||||
if (this.props.params.query != newProps.params.query || this.props.params.type != newProps.params.type){
|
||||
this.props.uiActions.startSearch(newProps.params.type, newProps.params.query)
|
||||
}
|
||||
|
||||
// mopidy comes online
|
||||
if (!this.props.mopidy_connected && newProps.mopidy_connected){
|
||||
this.props.uiActions.startSearch(newProps.params.type, newProps.params.query, true)
|
||||
// mopidy comes online
|
||||
if (!this.props.mopidy_connected && newProps.mopidy_connected){
|
||||
this.props.uiActions.startSearch(newProps.params.type, newProps.params.query, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,7 +243,7 @@ class Search extends React.Component{
|
||||
|
||||
return (
|
||||
<div className="view search-view">
|
||||
<Header icon="search" title="Search results" options={options} uiActions={this.props.uiActions} />
|
||||
<Header search options={options} uiActions={this.props.uiActions} />
|
||||
<div className="content-wrapper">
|
||||
{ this.renderResults() }
|
||||
</div>
|
||||
|
||||
@ -66,7 +66,11 @@ class Discover extends React.Component{
|
||||
}
|
||||
|
||||
handleURLSeeds(seeds_string = this.props.params.seeds){
|
||||
var seeds = seeds_string.split(',')
|
||||
|
||||
// Rejoin if we've had to uri-encode these as strings
|
||||
// We'd need to do this if our URL has been encoded so the whole URL can become
|
||||
// it's own URI (eg iris:discover:spotify_artist_1234) where we can't use ":"
|
||||
var seeds = seeds_string.split('_').join(':').split(',')
|
||||
|
||||
for (var i = 0; i < seeds.length; i++){
|
||||
switch (helpers.uriType(seeds[i])){
|
||||
@ -198,6 +202,11 @@ class Discover extends React.Component{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var uri = 'iris:discover'
|
||||
if (this.props.params.seeds){
|
||||
uri += ':'+this.props.params.seeds.split(':').join('_')
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="content-wrapper recommendations-results">
|
||||
@ -211,7 +220,7 @@ class Discover extends React.Component{
|
||||
</section>
|
||||
<section className="list-wrapper">
|
||||
<h4>Tracks</h4>
|
||||
{this.props.recommendations.tracks ? <TrackList className="discover-track-list" uri="iris:discover" tracks={this.props.recommendations.tracks} /> : null}
|
||||
{this.props.recommendations.tracks ? <TrackList className="discover-track-list" uri={uri} tracks={this.props.recommendations.tracks} /> : null}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user