Clear up to 1k unread notifications

This commit is contained in:
Johannes Zellner
2022-05-23 17:36:44 +02:00
parent c5b022cc19
commit 663e117da1
2 changed files with 14 additions and 20 deletions
+13 -19
View File
@@ -11,7 +11,6 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
$scope.notifications = [];
$scope.activeNotification = null;
$scope.busy = true;
$scope.hasUnread = false;
$scope.currentPage = 1;
$scope.perPage = 20;
@@ -30,7 +29,6 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
});
$scope.notifications = result;
$scope.hasUnread = !!result.find(function (n) { return !n.acknowledged; });
$scope.busy = false;
});
@@ -62,26 +60,22 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
$scope.clearAll = function () {
$scope.clearAllBusy = true;
async.eachLimit($scope.notifications, 20, function (notification, callback) {
if (notification.acknowledged) return callback();
Client.ackNotification(notification.id, true, function (error) {
if (error) {
console.error(error);
} else {
notification.acknowledged = true;
}
callback();
});
}, function (error) {
Client.getNotifications({ acknowledged: false }, 1, 1000, function (error, results) { // hopefully 1k unread is sufficient
if (error) console.error(error);
// refresh the main navbar indicator
$scope.$parent.notificationAcknowledged();
async.eachLimit(results, 20, function (notification, callback) {
Client.ackNotification(notification.id, true, function (error) {
if (error) console.error(error);
callback();
});
}, function (error) {
if (error) console.error(error);
$scope.hasUnread = false;
$scope.clearAllBusy = false;
// refresh the main navbar indicator
$scope.$parent.notificationAcknowledged();
$scope.clearAllBusy = false;
});
});
};