More universal processor style
This commit is contained in:
@ -176,6 +176,20 @@ export function startProcess(key,content){
|
||||
}
|
||||
}
|
||||
|
||||
export function updateProcess(key,content){
|
||||
return {
|
||||
type: 'UPDATE_PROCESS',
|
||||
key: key,
|
||||
content: content
|
||||
}
|
||||
}
|
||||
|
||||
export function runProcess(key){
|
||||
return {
|
||||
type: key
|
||||
}
|
||||
}
|
||||
|
||||
export function cancelProcess(key){
|
||||
return {
|
||||
type: 'CANCEL_PROCESS',
|
||||
@ -183,9 +197,9 @@ export function cancelProcess(key){
|
||||
}
|
||||
}
|
||||
|
||||
export function stopProcess(key){
|
||||
export function processFinished(key){
|
||||
return {
|
||||
type: 'STOP_PROCESS',
|
||||
type: 'PROCESS_FINISHED',
|
||||
key: key
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,13 +122,17 @@ const UIMiddleware = (function(){
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'START_PROCESS':
|
||||
store.dispatch({
|
||||
type: action.key
|
||||
})
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'CANCEL_PROCESS':
|
||||
if (action.key == 'MOPIDY_ENQUEUE_URIS'){
|
||||
store.dispatch(mopidyActions.enqueueURIsCancel())
|
||||
}
|
||||
if (action.key == 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR'){
|
||||
store.dispatch(mopidyActions.cancelProcessor(action.key))
|
||||
}
|
||||
store.dispatch({
|
||||
type: action.key+'_CANCEL'
|
||||
})
|
||||
next(action)
|
||||
break
|
||||
|
||||
|
||||
@ -126,6 +126,7 @@ export default function reducer(ui = {}, action){
|
||||
return Object.assign({}, ui, {load_queue: load_queue})
|
||||
|
||||
case 'START_PROCESS':
|
||||
case 'UPDATE_PROCESS':
|
||||
var processes = Object.assign({}, (ui.processes ? ui.processes : []))
|
||||
processes[action.key] = {
|
||||
key: action.key,
|
||||
@ -146,7 +147,7 @@ export default function reducer(ui = {}, action){
|
||||
}
|
||||
return Object.assign({}, ui, {processes: processes})
|
||||
|
||||
case 'STOP_PROCESS':
|
||||
case 'PROCESS_FINISHED':
|
||||
var processes = Object.assign({}, (ui.processes ? ui.processes : {}))
|
||||
if (processes[action.key]){
|
||||
delete processes[action.key]
|
||||
|
||||
Reference in New Issue
Block a user