Handling new api structure with client-triggered broadcasts

This commit is contained in:
James Barnsley
2018-03-20 13:02:38 +13:00
parent 2cde9fa786
commit 8549e9db85
10 changed files with 160 additions and 95 deletions

View File

@ -203,10 +203,11 @@ export function closeNotification(key){
}
}
export function removeNotification(key){
export function removeNotification(key, manual = false){
return {
type: 'REMOVE_NOTIFICATION',
key: key
key: key,
manual: manual
}
}

View File

@ -86,14 +86,6 @@ const UIMiddleware = (function(){
case 'CLOSE_NOTIFICATION':
var notifications = Object.assign({}, store.getState().ui.notifications);
// If a broadcast, add to suppressed_broadcasts
if (notifications[action.key] && notifications[action.key].type == 'broadcast'){
store.dispatch({
type: 'SUPPRESS_BROADCAST',
key: action.key
})
}
// start a timeout to remove this notification
// This gives us time to animate out the notification before we remove the data
var timeout = setTimeout(
@ -106,6 +98,24 @@ const UIMiddleware = (function(){
next(action);
break;
case 'REMOVE_NOTIFICATION':
// Manual removal
if (action.manual){
var notifications = Object.assign({}, store.getState().ui.notifications);
// If a broadcast, add to suppressed_broadcasts
if (notifications[action.key] && notifications[action.key].type == 'broadcast'){
store.dispatch({
type: 'SUPPRESS_BROADCAST',
key: action.key
})
}
}
next(action);
break;
case 'BROADCASTS_LOADED':
var suppressed_broadcasts = []
if (typeof(store.getState().ui.suppressed_broadcasts) !== 'undefined'){