Searching; Source icon on TrackList
This commit is contained in:
@ -162,3 +162,19 @@ export function getAlbums(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Other general actions
|
||||
**/
|
||||
|
||||
export function getSearchResults(query, fields = ['any'], backends = null){
|
||||
var queryObj = {};
|
||||
for( var i = 0; i < fields.length; i++ ){
|
||||
queryObj[fields[i]] = [query];
|
||||
}
|
||||
return {
|
||||
type: 'MOPIDY_INSTRUCT',
|
||||
call: 'library.search',
|
||||
value: { query: queryObj, uris: backends }
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ const MopidyMiddleware = (function(){
|
||||
instruct( ws, store, 'tracklist.getTlTracks' );
|
||||
instruct( ws, store, 'playback.getCurrentTlTrack' );
|
||||
instruct( ws, store, 'playback.getTimePosition' );
|
||||
instruct( ws, store, 'getUriSchemes' );
|
||||
break;
|
||||
|
||||
case 'state:offline':
|
||||
@ -78,15 +79,22 @@ const MopidyMiddleware = (function(){
|
||||
var callParts = call.split('.');
|
||||
var model = callParts[0];
|
||||
var method = callParts[1];
|
||||
var property = method;
|
||||
if( method ){
|
||||
var mopidyObject = ws[model][method]
|
||||
var property = method;
|
||||
}else{
|
||||
var mopidyObject = ws[model]
|
||||
var property = model;
|
||||
}
|
||||
|
||||
property = property.replace('get','');
|
||||
property = property.replace('set','');
|
||||
|
||||
return new Promise( (resolve, reject) => {
|
||||
ws[model][method]( value )
|
||||
mopidyObject( value )
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch({ type: 'MOPIDY_'+property.toUpperCase(), model: model, data: response });
|
||||
store.dispatch({ type: 'MOPIDY_'+property.toUpperCase(), call: call, data: response });
|
||||
resolve(response);
|
||||
},
|
||||
error => {
|
||||
|
||||
@ -23,13 +23,14 @@ export default function reducer(mopidy = {}, action){
|
||||
tlid: action.tlid
|
||||
});
|
||||
|
||||
case 'MOPIDY_PLAYLISTS_LOADED':
|
||||
if( !action.data ) return mopidy;
|
||||
return Object.assign({}, mopidy, { playlists: action.data });
|
||||
case 'MOPIDY_URISCHEMES':
|
||||
return Object.assign({}, mopidy, {
|
||||
uri_schemes: action.data
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Websocket-initiated actions
|
||||
* State-oriented actions
|
||||
**/
|
||||
case 'MOPIDY_STATE':
|
||||
return Object.assign({}, mopidy, {
|
||||
@ -51,6 +52,21 @@ export default function reducer(mopidy = {}, action){
|
||||
repeat: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_VOLUME':
|
||||
return Object.assign({}, mopidy, {
|
||||
volume: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_TIMEPOSITION':
|
||||
return Object.assign({}, mopidy, {
|
||||
time_position: action.data
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Asset-oriented actions
|
||||
**/
|
||||
|
||||
case 'MOPIDY_TLTRACKS':
|
||||
return Object.assign({}, mopidy, {
|
||||
tracks: action.data
|
||||
@ -71,15 +87,9 @@ export default function reducer(mopidy = {}, action){
|
||||
tracks: tracks
|
||||
});
|
||||
|
||||
case 'MOPIDY_VOLUME':
|
||||
return Object.assign({}, mopidy, {
|
||||
volume: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_TIMEPOSITION':
|
||||
return Object.assign({}, mopidy, {
|
||||
time_position: action.data
|
||||
});
|
||||
case 'MOPIDY_PLAYLISTS_LOADED':
|
||||
if( !action.data ) return mopidy;
|
||||
return Object.assign({}, mopidy, { playlists: action.data });
|
||||
|
||||
case 'MOPIDY_DIRECTORY_LOADED':
|
||||
return Object.assign({}, mopidy, {
|
||||
@ -111,6 +121,15 @@ export default function reducer(mopidy = {}, action){
|
||||
albums: action.data
|
||||
});
|
||||
|
||||
case 'MOPIDY_SEARCH':
|
||||
var results = []
|
||||
for( var i = 0; i < action.data.length; i++ ){
|
||||
results = [...results, ...action.data[i].tracks]
|
||||
}
|
||||
return Object.assign({}, mopidy, {
|
||||
search_results_tracks: results
|
||||
});
|
||||
|
||||
default:
|
||||
return mopidy
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user