Processor cancelled vs finished; Re-run processor if incomplete during next render

This commit is contained in:
James Barnsley
2017-08-15 16:36:50 +12:00
parent 6f0088204b
commit f51e83099e
14 changed files with 156 additions and 106 deletions

View File

@ -852,6 +852,9 @@ const MopidyMiddleware = (function(){
**/
case 'MOPIDY_GET_LIBRARY_ALBUMS':
store.dispatch({type: 'MOPIDY_LIBRARY_ALBUMS_CLEAR'})
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=album' } )
.then( response => {
if (response.length <= 0) return
@ -872,7 +875,7 @@ const MopidyMiddleware = (function(){
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ALBUMS_PROCESSOR']
if (processor.cancelling){
store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'))
store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'))
return false
}
}
@ -1003,6 +1006,9 @@ const MopidyMiddleware = (function(){
**/
case 'MOPIDY_GET_LIBRARY_ARTISTS':
store.dispatch({type: 'MOPIDY_LIBRARY_ARTISTS_CLEAR'})
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
.then( response => {
if (response.length <= 0) return
@ -1024,7 +1030,7 @@ const MopidyMiddleware = (function(){
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR']
if (processor.cancelling){
store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
return false
}
}

View File

@ -151,6 +151,35 @@ export default function reducer(mopidy = {}, action){
}
return Object.assign({}, mopidy, { library_albums: uris })
case 'MOPIDY_LIBRARY_PLAYLISTS_CLEAR':
return Object.assign({}, mopidy, { library_playlists: [] })
case 'MOPIDY_LIBRARY_ARTISTS_CLEAR':
return Object.assign({}, mopidy, { library_artists: [] })
case 'MOPIDY_LIBRARY_ALBUMS_CLEAR':
return Object.assign({}, mopidy, { library_albums: [] })
case 'MOPIDY_LIBRARY_PLAYLISTS_PROCESSOR_CANCELLED':
return Object.assign({}, mopidy, { library_playlists_status: 'cancelled' })
case 'MOPIDY_LIBRARY_PLAYLISTS_PROCESSOR_FINISHED':
return Object.assign({}, mopidy, { library_playlists_status: 'finished' })
case 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR_CANCELLED':
return Object.assign({}, mopidy, { library_artists_status: 'cancelled' })
case 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR_FINISHED':
return Object.assign({}, mopidy, { library_artists_status: 'finished' })
case 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR_CANCELLED':
return Object.assign({}, mopidy, { library_albums_status: 'cancelled' })
case 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR_FINISHED':
return Object.assign({}, mopidy, { library_albums_status: 'finished' })
default:
return mopidy
}