Queue metadata endpoint

This commit is contained in:
James Barnsley
2017-02-14 12:13:07 +13:00
parent 7184fad11f
commit 02d3868d1e
12 changed files with 113 additions and 16 deletions

View File

@ -56,15 +56,17 @@ export function playURIs( uris ){
}
}
export function enqueueURIsNext( uris ){
export function enqueueURIsNext( uris, from_uri = null ){
if( typeof(uris) !== 'object' ) uris = [uris]
return {
type: 'MOPIDY_ENQUEUE_URIS_NEXT',
uris: uris
uris: uris,
from_uri: from_uri
}
}
export function enqueueURIs( uris, at_position = false ){
// TODO: Create separate action type for this, rather than using _INSTRUCT
export function enqueueURIs( uris, from_uri = null, at_position = false ){
if( typeof(uris) !== 'object' ) uris = [uris];
var value = { uris: uris };
if( at_position ) value.at_position = at_position;

View File

@ -238,10 +238,13 @@ const MopidyMiddleware = (function(){
var current_track = store.getState().ui.current_track
var current_tracklist = store.getState().ui.current_tracklist
var current_track_index = -1
for( var i = 0; i < current_tracklist.length; i++ ){
if( current_tracklist[i].tlid == current_track.tlid ){
current_track_index = i
break
if (typeof(current_track) !== 'undefined'){
for( var i = 0; i < current_tracklist.length; i++ ){
if( current_tracklist[i].tlid == current_track.tlid ){
current_track_index = i
break
}
}
}
@ -249,6 +252,13 @@ const MopidyMiddleware = (function(){
if( current_track_index > -1 ) at_position = current_track_index + 1
instruct( socket, store, 'tracklist.add', { uris: action.uris, at_position: at_position } )
.then( response => {
var tlids = []
for (var i = 0; i < response.length; i++){
tlids.push(response[i].tlid)
}
store.dispatch( pusherActions.addQueueMetadata(tlids, action.from_uri) )
})
break
case 'MOPIDY_PLAY_URIS':