-
-
-
{
this.props.uri_schemes.map(scheme => {
return (
diff --git a/src/js/components/Sidebar.js b/src/js/components/Sidebar.js
index 138bacff..1ed4bf96 100755
--- a/src/js/components/Sidebar.js
+++ b/src/js/components/Sidebar.js
@@ -90,6 +90,7 @@ class Sidebar extends React.Component{
Settings
+ { this.props.test_mode ?
: null}
{ !this.props.mopidy_connected || (!this.props.spotify_connected && this.props.spotify_enabled) || !this.props.pusher_connected ?
: null }
@@ -118,6 +119,7 @@ const mapStateToProps = (state, ownProps) => {
spotify_enabled: state.spotify.enabled,
spotify_connected: state.spotify.connected,
spotify_authorized: state.spotify.authorization,
+ test_mode: (state.ui.test_mode ? state.ui.test_mode : false),
dragger: state.ui.dragger
}
}
diff --git a/src/js/services/mopidy/middleware.js b/src/js/services/mopidy/middleware.js
index a0908751..75e6304a 100755
--- a/src/js/services/mopidy/middleware.js
+++ b/src/js/services/mopidy/middleware.js
@@ -496,7 +496,8 @@ const MopidyMiddleware = (function(){
context: action.context,
query: action.query,
limit: action.limit,
- schemes: store.getState().ui.search_settings.uri_schemes
+ total: uri_schemes.length,
+ uri_schemes: store.getState().ui.search_settings.uri_schemes
}
));
break
@@ -504,39 +505,62 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR':
+ var uri_schemes = Object.assign([], action.data.uri_schemes)
+ var uri_scheme = uri_schemes.shift()
- console.log(action.data.schemes)
- break
+ switch (action.data.context){
-
-
-
-
-/*
- switch (action.context){
-
- // Tracks
- case 'tracks':
- instruct( socket, store, 'library.search', {query: {any: [action.query]}, uris: [action.uri_scheme]})
+ // Albums
+ case 'albums':
+ instruct( socket, store, 'library.search', {query: {album: [action.data.query]}, uris: [uri_scheme]})
.then( response => {
+ console.log(response)
if (response.length <= 0) return
- if (typeof(response[0].tracks) === 'undefined') return
- var tracks = response[0].tracks.splice(0,action.limit)
+ // collate all our different sources into one array
+ var albums_uris = []
+ if (response[0].tracks){
+ for (var i = 0; i < response[0].tracks.length; i++){
+ if (response[0].tracks[i].album){
+ var album = response[0].tracks[i].album
+ if (album.uri){
+ albums_uris.push(album.uri)
+ }
+ }
+ }
+ }
+ // TODO: limit uris at the loop, rather than post loop for performance
+ albums_uris = helpers.removeDuplicates(albums_uris).splice(0, action.limit)
+
+ // load each album
+ for (var i = 0; i < albums_uris.length; i++){
+ store.dispatch(mopidyActions.getAlbum(albums_uris[i]))
+ }
+
+ // and plug in their URIs
store.dispatch({
- type: 'MOPIDY_SEARCH_RESULTS_LOADED',
- context: action.context,
- results: tracks
- });
+ type: 'MOPIDY_SEARCH_RESULTS_LOADED',
+ context: action.data.context,
+ results: albums_uris
+ })
- store.dispatch(uiActions.processFinished('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'))
+ store.dispatch(uiActions.processFinished(
+ 'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
+ 'Searching '+uri_scheme,
+ {
+ context: action.data.context,
+ query: action.data.query,
+ limit: action.data.limit,
+ uri_schemes: uri_schemes
+ })
+ )
})
break
// Artists
case 'artists':
- instruct( socket, store, 'library.search', {query: {artist: [action.query]}, uris: [action.uri_scheme]})
+ instruct( socket, store, 'library.search', {query: {artist: [action.data.query]}, uris: [uri_scheme]})
.then( response => {
if (response.length <= 0) return
@@ -565,7 +589,7 @@ const MopidyMiddleware = (function(){
// and plug in their URIs
store.dispatch({
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
- context: action.context,
+ context: action.data.context,
results: artists_uris
})
@@ -573,44 +597,6 @@ const MopidyMiddleware = (function(){
})
break
- // Albums
- case 'albums':
- instruct( socket, store, 'library.search', {query: {album: [action.query]}, uris: [action.uri_scheme]})
- .then( response => {
- if (response.length <= 0) return
-
- // collate all our different sources into one array
- var albums_uris = []
- if (response[0].tracks){
- for (var i = 0; i < response[0].tracks.length; i++){
- if (response[0].tracks[i].album){
- var album = response[0].tracks[i].album
- if (album.uri){
- albums_uris.push(album.uri)
- }
- }
- }
- }
-
- // TODO: limit uris at the loop, rather than post loop for performance
- albums_uris = helpers.removeDuplicates(albums_uris).splice(0, action.limit)
-
- // load each album
- for (var i = 0; i < albums_uris.length; i++){
- store.dispatch(mopidyActions.getAlbum(albums_uris[i]))
- }
-
- // and plug in their URIs
- store.dispatch({
- type: 'MOPIDY_SEARCH_RESULTS_LOADED',
- context: action.context,
- results: albums_uris
- })
-
- store.dispatch(uiActions.processFinished('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'))
- })
- break
-
// Playlists
case 'playlists':
instruct( socket, store, 'playlists.asList')
@@ -635,7 +621,7 @@ const MopidyMiddleware = (function(){
// and plug in their URIs
store.dispatch({
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
- context: action.context,
+ context: action.data.context,
results: playlists_uris
})
@@ -643,8 +629,26 @@ const MopidyMiddleware = (function(){
})
break
+ // Tracks
+ case 'tracks':
+ instruct( socket, store, 'library.search', {query: {any: [action.data.query]}, uris: [uri_scheme]})
+ .then( response => {
+ if (response.length <= 0) return
+ if (typeof(response[0].tracks) === 'undefined') return
+
+ var tracks = response[0].tracks.splice(0,action.limit)
+
+ store.dispatch({
+ type: 'MOPIDY_SEARCH_RESULTS_LOADED',
+ context: action.data.context,
+ results: tracks
+ });
+
+ store.dispatch(uiActions.processFinished('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'))
+ })
+ break
+
}
- */
break
diff --git a/src/js/services/spotify/actions.js b/src/js/services/spotify/actions.js
index f5b65928..8ee90fb2 100755
--- a/src/js/services/spotify/actions.js
+++ b/src/js/services/spotify/actions.js
@@ -443,7 +443,7 @@ export function getURL( url, action_name, key = false ){
}
}
-export function getSearchResults(query, type = 'album,artist,playlist,track', limit = 50, offset = 0){
+export function getSearchResults(type = 'album,artist,playlist,track', query, limit = 50, offset = 0){
return (dispatch, getState) => {
dispatch(uiActions.startProcess('SPOTIFY_GET_SEARCH_RESULTS_PROCESSOR','Searching Spotify'))
diff --git a/src/js/views/Search.js b/src/js/views/Search.js
index 401b7683..daf6577d 100755
--- a/src/js/views/Search.js
+++ b/src/js/views/Search.js
@@ -29,33 +29,31 @@ class Search extends React.Component{
componentDidMount(){
- // Make sure we have search parameters to start with
- 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
$(document).find('.search-form input').focus();
+
+ if (this.props.mopidy_connected && this.props.search_settings.uri_schemes){
+ this.props.mopidyActions.getSearchResults(this.props.view, this.props.params.query)
+ }
+
+ if (this.props.mopidy_connected && this.props.search_settings.uri_schemes && this.props.search_settings.uri_schemes.includes('spotify')){
+ this.props.spotifyActions.getSearchResults(this.props.view, this.props.params.query)
+ }
}
componentWillReceiveProps(newProps){
-
- // Make sure we have some search parameters
- if (newProps.params && newProps.view && newProps.params.query){
+ if (!this.props.mopidy_connected && newProps.mopidy_connected){
+ this.props.mopidyActions.getSearchResults(newProps.view, 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.view, newProps.params.query, true)
- }
+ if (!this.props.spotify_connected && newProps.spotify_connected && newProps.search_settings.uri_schemes.includes('spotify')){
+ this.props.spotifyActions.getSearchResults(newProps.view, newProps.params.query)
}
}
loadMore(type){
- this.props.spotifyActions.getURL( this.props['spotify_'+type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+type.toUpperCase());
+ alert('load more: '+type)
+ //this.props.spotifyActions.getURL( this.props['spotify_'+type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+type.toUpperCase());
}
renderResults(){
diff --git a/src/js/views/Settings.js b/src/js/views/Settings.js
index a20aca45..6d668649 100755
--- a/src/js/views/Settings.js
+++ b/src/js/views/Settings.js
@@ -203,6 +203,7 @@ class Settings extends React.Component {
diff --git a/src/scss/global/_core.scss b/src/scss/global/_core.scss
index 2cdeb211..d10086f4 100755
--- a/src/scss/global/_core.scss
+++ b/src/scss/global/_core.scss
@@ -268,6 +268,7 @@ button.placeholder {
.grey-text { color: $mid_grey !important; }
.dark-grey-text { color: lighten($dark_grey, 8%) !important; }
.red-text { color: $red !important; }
+.blue-text { color: $blue !important; }
.green-text { color: $green !important; }
.orange-text { color: $orange !important; }
.dark-text { color: $dark_grey !important; }
@@ -314,6 +315,20 @@ footer {
color: $white;
}
+ &.info {
+ background: $yellow;
+ }
+
+ &.warning {
+ background: $orange;
+ color: $white;
+ }
+
+ &.bad {
+ background: $red;
+ color: $white;
+ }
+
&.dark {
background: lighten($dark_grey,10%);
color: $mid_grey;