Cancellable processes
This commit is contained in:
@ -262,10 +262,11 @@ export function stopLoading(key){
|
||||
}
|
||||
}
|
||||
|
||||
export function startProcess(key){
|
||||
export function startProcess(key,content){
|
||||
return {
|
||||
type: 'START_PROCESS',
|
||||
key: key
|
||||
key: key,
|
||||
content: content
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -268,15 +268,13 @@ const UIMiddleware = (function(){
|
||||
|
||||
case 'CREATE_NOTIFICATION':
|
||||
|
||||
// start a timeout to remove this (non loading) notification
|
||||
if (action.notification.type != 'process'){
|
||||
var timeout = setTimeout(
|
||||
function(){
|
||||
store.dispatch(uiActions.removeNotification(action.notification.key))
|
||||
},
|
||||
(action.notification.type == 'shortcut' ? 1000 : 3000)
|
||||
)
|
||||
}
|
||||
// start a timeout to remove this notification
|
||||
var timeout = setTimeout(
|
||||
function(){
|
||||
store.dispatch(uiActions.removeNotification(action.notification.key))
|
||||
},
|
||||
(action.notification.type == 'shortcut' ? 1000 : 3000)
|
||||
)
|
||||
|
||||
next(action)
|
||||
break
|
||||
|
||||
@ -745,7 +745,23 @@ export default function reducer(ui = {}, action){
|
||||
|
||||
case 'START_PROCESS':
|
||||
var processes = Object.assign({}, (ui.processes ? ui.processes : []))
|
||||
processes[action.key] = 'active'
|
||||
processes[action.key] = {
|
||||
key: action.key,
|
||||
content: action.content
|
||||
}
|
||||
return Object.assign({}, ui, {processes: processes})
|
||||
|
||||
case 'CANCEL_PROCESS':
|
||||
var processes = Object.assign({}, (ui.processes ? ui.processes : {}))
|
||||
if (processes[action.key]){
|
||||
processes[action.key] = Object.assign(
|
||||
{},
|
||||
processes[action.key],
|
||||
{
|
||||
cancelling: true
|
||||
}
|
||||
)
|
||||
}
|
||||
return Object.assign({}, ui, {processes: processes})
|
||||
|
||||
case 'STOP_PROCESS':
|
||||
|
||||
Reference in New Issue
Block a user