Cancelling of Adding URIs

This commit is contained in:
James Barnsley
2017-05-05 04:06:06 +12:00
parent fe01461b7b
commit 4946d21850
3 changed files with 19 additions and 3 deletions

View File

@ -67,6 +67,12 @@ export function enqueueURIs(uris, from_uri = null, next = false, at_position = n
}
}
export function enqueueURIsCancel(){
return {
type: 'MOPIDY_ENQUEUE_URIS_CANCEL'
}
}
export function enqueueURIsBatchDone(){
return {
type: 'MOPIDY_ENQUEUE_URIS_BATCH_DONE'

View File

@ -284,7 +284,6 @@ const MopidyMiddleware = (function(){
break
case 'MOPIDY_ENQUEUE_URIS':
console.log(action)
// split into batches
var uris = Object.assign([], action.uris)
@ -298,7 +297,7 @@ const MopidyMiddleware = (function(){
})
}
// pass off this modified action to the reducer (and other middleware)
// pass this modified action to the reducer (and other middleware)
action.batches = batches
next(action)
@ -307,7 +306,6 @@ const MopidyMiddleware = (function(){
break
case 'MOPIDY_ENQUEUE_URIS_PROCESSOR':
console.log(action)
// make sure we have some uris in the queue
if (store.getState().mopidy.enqueue_uris_batches && store.getState().mopidy.enqueue_uris_batches.length > 0){
@ -366,6 +364,13 @@ const MopidyMiddleware = (function(){
break
case 'CANCEL_PROCESS':
if (action.key == 'MOPIDY_ENQUEUE_URIS'){
store.dispatch(mopidyActions.enqueueURIsCancel())
}
next(action)
break
case 'MOPIDY_PLAY_URIS':
// stop the radio

View File

@ -99,6 +99,11 @@ export default function reducer(mopidy = {}, action){
enqueue_uris_batches: batches
});
case 'MOPIDY_ENQUEUE_URIS_CANCEL':
return Object.assign({}, mopidy, {
enqueue_uris_batches: []
});
case 'MOPIDY_ENQUEUE_URIS_BATCH_DONE':
if (!mopidy.enqueue_uris_batches || mopidy.enqueue_uris_batches.length <= 0){
var batches = []