diff --git a/src/js/main.js b/src/js/main.js index e7ff35305..8a665c494 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -71,8 +71,9 @@ angular.module('Application').controller('MainController', ['$scope', '$route', } // update state of acknowledged notification - $scope.notificationAcknowledged = function (ack) { - $scope.notificationCount += (ack ? -1 : +1); + $scope.notificationAcknowledged = function () { + if ($scope.notificationCount === 0) return; // already down to 0 + $scope.notificationCount--; }; function init() { diff --git a/src/views/notifications.html b/src/views/notifications.html index b7089e46f..b039f504d 100644 --- a/src/views/notifications.html +++ b/src/views/notifications.html @@ -25,10 +25,7 @@
{{ notification.messageJson | json }}
diff --git a/src/views/notifications.js b/src/views/notifications.js
index c3d85ea09..7349fde38 100644
--- a/src/views/notifications.js
+++ b/src/views/notifications.js
@@ -46,16 +46,14 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
$scope.refresh();
};
- $scope.ack = function (notification, acked, event) {
- if (event) event.stopPropagation();
+ $scope.ack = function (notification) {
+ if (notification.acknowledged) return;
- if (notification.acknowledged === acked) return;
-
- Client.ackNotification(notification.id, acked, function (error) {
+ Client.ackNotification(notification.id, true, function (error) {
if (error) console.error(error);
- notification.acknowledged = acked;
- $scope.$parent.notificationAcknowledged(acked);
+ notification.acknowledged = true;
+ $scope.$parent.notificationAcknowledged();
});
};
@@ -70,7 +68,7 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
console.error(error);
} else {
notification.acknowledged = true;
- $scope.$parent.notificationAcknowledged(true);
+ $scope.$parent.notificationAcknowledged();
}
callback();