prevent past CLEAR notifications; fixes #1035
Costa Tsaousis (ktsaou) committed
Sep 29, 2016 at 11:19 UTC
7a35442ff7f7de4c4a00496068eb60ef8a8b40f7
1 file changed
+6
-3
web/dashboard.js
+6
-3
@@ -5621,7 +5621,8 @@
5621
5622
notifications: false, // when true, the browser supports notifications (may not be granted though)
5623
last_notification_id: 0, // the id of the last alarm_log we have raised an alarm for
5624
- first_notification_id: 0, // the id of the first alarm_log we have seen in this session
5624
+ first_notification_id: 0, // the id of the first alarm_log entry for this session
5625
+ // this is used to prevent CLEAR notifications for past events
5626
// notifications_shown: new Array(),
5627
5628
server: null, // the server to connect to for fetching alarms
@@ -5666,7 +5667,7 @@
5667
return;
5668
5669
case 'CLEAR':
5669
- if(typeof entry.updates_id === 'number' && entry.updates_id < NETDATA.alarms.first_notification_id) {
5670
+ if(entry.unique_id < NETDATA.alarms.first_notification_id) {
5671
// console.log('alarm ' + entry.unique_id + ' is not current');
5672
return;
5673
}
@@ -5843,6 +5844,9 @@
5844
xhrFields: { withCredentials: true } // required for the cookie
5845
})
5846
.done(function(data) {
5847
+ if(NETDATA.alarms.first_notification_id === 0 && typeof data.latest_alarm_log_unique_id === 'number')
5848
+ NETDATA.alarms.first_notification_id = data.latest_alarm_log_unique_id;
5849
+
5850
if(typeof callback === 'function')
5851
callback(data);
5852
})
@@ -5902,7 +5906,6 @@
5906
NETDATA.alarms.server = host;
5907
5908
NETDATA.alarms.last_notification_id = NETDATA.localStorageGet('last_notification_id', NETDATA.alarms.last_notification_id, null);
5905
- NETDATA.alarms.first_notification_id = NETDATA.alarms.last_notification_id;
5909
5910
if(NETDATA.alarms.onclick === null)
5911
NETDATA.alarms.onclick = NETDATA.alarms.scrollToAlarm;