Run ack code 20 in parallel
only trigger refresh at the end of it all
This commit is contained in:
@@ -60,21 +60,26 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
$scope.notifications.activeNotification = notification;
|
||||
},
|
||||
|
||||
ack: function (notification, event, callback) {
|
||||
callback = callback || function (error) { if (error) console.error(error); };
|
||||
|
||||
if (event) event.stopPropagation();
|
||||
|
||||
Client.ackNotification(notification.id, function (error) {
|
||||
ackOne: function (id, callback) {
|
||||
Client.ackNotification(id, function (error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
$scope.$parent.notificationAcknowledged(notification.id);
|
||||
$scope.notifications.refresh();
|
||||
$scope.$parent.notificationAcknowledged(id);
|
||||
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
ack: function (notification, event) {
|
||||
event.stopPropagation();
|
||||
|
||||
$scope.notifications.ackOne(notification.id, function (error) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.notifications.refresh();
|
||||
});
|
||||
},
|
||||
|
||||
action: function (notification) {
|
||||
if (notification.action) window.location = notification.action;
|
||||
},
|
||||
@@ -82,12 +87,13 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
clearAll: function () {
|
||||
$scope.clearAllBusy = true;
|
||||
|
||||
async.eachSeries($scope.notifications.notifications, function (notification, callback) {
|
||||
async.eachLimit($scope.notifications.notifications, 20, function (notification, callback) {
|
||||
if (notification.acknowledged) return callback();
|
||||
$scope.notifications.ack(notification, null /* no click event */, callback);
|
||||
$scope.notifications.ackOne(notification, callback);
|
||||
}, function (error) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.notifications.refresh();
|
||||
$scope.clearAllBusy = false;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user