Metadata operational; Handle cached/local lookups that are instant; Remove old tlids
This commit is contained in:
@ -49,10 +49,11 @@ export function changeTrack( tlid ){
|
||||
}
|
||||
}
|
||||
|
||||
export function playURIs( uris ){
|
||||
export function playURIs( uris, from_uri = null ){
|
||||
return {
|
||||
type: 'MOPIDY_PLAY_URIS',
|
||||
uris: uris
|
||||
uris: uris,
|
||||
from_uri: from_uri
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,15 +66,12 @@ export function enqueueURIsNext( uris, from_uri = null ){
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
return {
|
||||
type: 'MOPIDY_INSTRUCT',
|
||||
call: 'tracklist.add',
|
||||
value: value
|
||||
type: 'MOPIDY_ENQUEUE_URIS',
|
||||
uris: uris,
|
||||
at_position: at_position,
|
||||
from_uri: from_uri
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -233,6 +233,22 @@ const MopidyMiddleware = (function(){
|
||||
})
|
||||
break;
|
||||
|
||||
case 'MOPIDY_ENQUEUE_URIS':
|
||||
var value = { uris: action.uris }
|
||||
if (action.at_position){
|
||||
value.at_position = action.at_position
|
||||
}
|
||||
|
||||
instruct( socket, store, 'tracklist.add', value )
|
||||
.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_ENQUEUE_URIS_NEXT':
|
||||
|
||||
var current_track = store.getState().ui.current_track
|
||||
@ -273,16 +289,22 @@ const MopidyMiddleware = (function(){
|
||||
.then( response => {
|
||||
|
||||
if( !response || response.length <= 0 ){
|
||||
store.dispatch( uiActions.createNotification('Could not add URI(s) to tracklist', 'error') )
|
||||
store.dispatch( uiActions.createNotification('Failed to load URI(s)', 'bad') )
|
||||
}else{
|
||||
// play it
|
||||
store.dispatch( mopidyActions.changeTrack( response[0].tlid ) );
|
||||
store.dispatch( mopidyActions.changeTrack( response[0].tlid ) );
|
||||
|
||||
var tlids = []
|
||||
for (var i = 0; i < response.length; i++){
|
||||
tlids.push(response[i].tlid)
|
||||
}
|
||||
store.dispatch( pusherActions.addQueueMetadata(tlids, action.from_uri) )
|
||||
}
|
||||
|
||||
// add the rest of our uris (if any)
|
||||
action.uris.shift();
|
||||
if( action.uris.length > 0 ){
|
||||
store.dispatch( mopidyActions.enqueueURIs( action.uris, 1 ) )
|
||||
store.dispatch( mopidyActions.enqueueURIs( action.uris, action.from_uri, 1 ) )
|
||||
}
|
||||
})
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user