From 663e117da19ae660b9d66e68aeeae0931dd4ae08 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 23 May 2022 17:36:44 +0200 Subject: [PATCH] Clear up to 1k unread notifications --- src/views/notifications.html | 2 +- src/views/notifications.js | 32 +++++++++++++------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/views/notifications.html b/src/views/notifications.html index 2a4cb6beb..3d5eaae48 100644 --- a/src/views/notifications.html +++ b/src/views/notifications.html @@ -6,7 +6,7 @@
- +
diff --git a/src/views/notifications.js b/src/views/notifications.js index 03445bb76..1af489008 100644 --- a/src/views/notifications.js +++ b/src/views/notifications.js @@ -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; + }); }); };