diff --git a/src/js/components/URISchemesList.js b/src/js/components/URISchemesList.js index cfba4178..15bd246a 100755 --- a/src/js/components/URISchemesList.js +++ b/src/js/components/URISchemesList.js @@ -8,16 +8,16 @@ import FontAwesome from 'react-fontawesome' class URISchemesList extends React.Component{ constructor(props) { - super(props); + super(props) } render(){ - if( !this.props.mopidy.uri_schemes ) return null; + if( !this.props.uri_schemes ) return null; return (
{ - this.props.mopidy.uri_schemes.map( (scheme, index) => { + this.props.uri_schemes.map( (scheme, index) => { scheme = scheme.replace(':','') return ( @@ -26,7 +26,7 @@ class URISchemesList extends React.Component{ { scheme } - ); + ) }) }
@@ -35,7 +35,9 @@ class URISchemesList extends React.Component{ } const mapStateToProps = (state, ownProps) => { - return state; + return { + uri_schemes: (state.mopidy.uri_schemes ? state.mopidy.uri_schemes : []) + } } export default connect(mapStateToProps)(URISchemesList) \ No newline at end of file diff --git a/src/js/index.js b/src/js/index.js index 3b6ca29c..ca922a89 100755 --- a/src/js/index.js +++ b/src/js/index.js @@ -61,7 +61,7 @@ ReactDOM.render( - + diff --git a/src/js/views/Search.js b/src/js/views/Search.js index 3b3e1049..5014ea71 100755 --- a/src/js/views/Search.js +++ b/src/js/views/Search.js @@ -42,9 +42,18 @@ class Search extends React.Component{ } performSearch( props = this.props ){ + var source = props.params.source + var type = props.params.type + this.props.uiActions.startSearch(props.params.query) - this.props.spotifyActions.getSearchResults( props.params.query ) - if( props.mopidy_connected ) this.props.mopidyActions.getSearchResults( props.params.query, props.uri_schemes ) + + if (!source || source == 'all' || source == 'spotify'){ + this.props.spotifyActions.getSearchResults( props.params.query ) + } + + if( props.mopidy_connected ){ + this.props.mopidyActions.getSearchResults( props.params.query, props.uri_schemes ) + } } loadMore(type){ @@ -164,15 +173,22 @@ class Search extends React.Component{ } } - handleViewChange(val){ + handleTypeChange(val){ this.props.uiActions.hideContextMenu() - hashHistory.push(global.baseURL+'search/'+this.props.params.query+'/'+val) + var source = (this.props.params.source ? this.props.params.source : 'all') + hashHistory.push(global.baseURL+'search/'+this.props.params.query+'/'+source+'/'+val) + } + + handleSourceChange(val){ + this.props.uiActions.hideContextMenu() + var type = (this.props.params.type ? this.props.params.type : 'all') + hashHistory.push(global.baseURL+'search/'+this.props.params.query+'/'+val+'/'+type) } render(){ - var view_options = [ + var type_options = [ { - value: '', + value: 'all', label: 'All' }, { @@ -193,9 +209,28 @@ class Search extends React.Component{ } ] + var source_options = [ + { + value: 'all', + label: 'All' + }, + { + value: 'spotify', + label: 'Spotify' + } + ] + for (var i = 0; i < this.props.uri_schemes.length; i++){ + var scheme = this.props.uri_schemes[i].replace(':','') + source_options.push({ + value: scheme, + label: scheme + }) + } + var options = ( - this.handleViewChange(val)} /> + this.handleTypeChange(val)} /> + this.handleSourceChange(val)} /> )