Fixing search collation of Spotify and Mopidy sources (still need to implement _more)

This commit is contained in:
James Barnsley
2017-01-18 09:09:24 +13:00
parent d0d92b807a
commit 14ee58f3b8
6 changed files with 58 additions and 60 deletions

View File

@ -206,20 +206,12 @@ export function getAlbums(){
* Other general actions
**/
export function getSearchResults(query, backends = null, fields = ['any']){
var queryObj = {};
for( var i = 0; i < fields.length; i++ ){
queryObj[fields[i]] = [query];
}
export function getSearchResults(query, uris = null, fields = ['any']){
return {
type: 'NOTHING'
type: 'MOPIDY_GET_SEARCH_RESULTS',
query: query,
uris: uris,
fields: fields
}
/*
return {
type: 'MOPIDY_INSTRUCT',
call: 'library.search',
value: { query: queryObj, uris: backends }
}
*/
}

View File

@ -282,6 +282,25 @@ const MopidyMiddleware = (function(){
})
break;
case 'MOPIDY_GET_SEARCH_RESULTS':
var queryObject = {};
for( var i = 0; i < action.fields.length; i++ ){
queryObject[action.fields[i]] = [action.query];
}
instruct( socket, store, 'library.search', {query: queryObject, uris: action.uris})
.then( response => {
// collate all our different sources into one array
var tracks = []
for( var i = 0; i < response.length; i++ ){
if( response[i].tracks ) tracks = [...tracks, ...response[i].tracks]
}
store.dispatch({ type: 'SEARCH_RESULTS_LOADED', tracks: tracks });
})
break;
/**
* =============================================================== PLAYLIST(S) ==========