| Index: lib/notification.js |
| diff --git a/lib/notification.js b/lib/notification.js |
| index 51ed5091da72b4ceb6a87d21cd60a6e7fd1af124..e197a5263c6170a6580bb83a10c851f1d9789e9c 100644 |
| --- a/lib/notification.js |
| +++ b/lib/notification.js |
| @@ -33,7 +33,8 @@ var EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; |
| var TYPE = { |
| information: 0, |
| question: 1, |
| - critical: 2 |
| + relentless: 2, |
| + critical: 3 |
| }; |
| var showListeners = []; |
| @@ -208,9 +209,21 @@ var Notification = exports.Notification = |
| { |
| if (typeof notification.type === "undefined" || notification.type !== "critical") |
| { |
| - let shown = Prefs.notificationdata.shown; |
| - if (shown instanceof Array && shown.indexOf(notification.id) != -1) |
| - continue; |
| + let shown = undefined; |
|
Sebastian Noack
2017/01/06 11:21:08
Initializing a variable with undefined is equivale
wspee
2017/01/06 14:08:51
Done.
|
| + if (Prefs.notificationdata.shown instanceof Object) |
|
Sebastian Noack
2017/01/06 11:21:08
Checking for the prototype seems unnecessary here.
wspee
2017/01/06 14:08:51
Done.
|
| + shown = Prefs.notificationdata.shown[notification.id]; |
| + |
| + if (typeof shown !== "undefined") |
|
Sebastian Noack
2017/01/06 11:21:08
As per the Mozilla coding style guide (https://dev
wspee
2017/01/06 14:08:51
Done.
|
| + { |
| + if (typeof notification.interval === "number") |
|
Sebastian Noack
2017/01/06 11:21:07
Same here, use == instead of ===.
wspee
2017/01/06 14:08:51
Done.
|
| + { |
| + if (shown + notification.interval > Date.now()) |
| + continue |
|
Sebastian Noack
2017/01/06 11:21:08
For consistency, please add the optional semicolon
wspee
2017/01/06 14:08:51
Done.
|
| + } |
| + else if (shown) |
| + continue |
|
Sebastian Noack
2017/01/06 11:21:07
For consistency, please add the optional semicolon
wspee
2017/01/06 14:08:51
Done.
|
| + } |
| + |
| if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) |
| continue; |
| } |
| @@ -287,14 +300,22 @@ var Notification = exports.Notification = |
| */ |
| markAsShown: function(id) |
| { |
| - var data = Prefs.notificationdata; |
| + let now = Date.now(); |
| + let data = Prefs.notificationdata; |
| - if (!(data.shown instanceof Array)) |
| - data.shown = []; |
| - if (data.shown.indexOf(id) != -1) |
| - return; |
| + if (data.shown instanceof Array) |
| + { |
| + let newShown = {} |
|
Sebastian Noack
2017/01/06 11:21:08
For consistency, please add the optional semicolon
wspee
2017/01/06 14:08:51
Done.
|
| + for (let old_id of data.shown) |
| + newShown[old_id] = now; |
| + data.shown = newShown; |
| + } |
| + |
| + if (!(data.shown instanceof Object)) |
|
Sebastian Noack
2017/01/06 11:21:08
See above, you should probably use typeof here.
wspee
2017/01/06 14:08:51
Done.
|
| + data.shown = {}; |
| + |
| + data.shown[id] = Date.now(); |
|
Sebastian Noack
2017/01/06 11:21:08
I suppose, we should use the "now" variable here a
wspee
2017/01/06 14:08:51
Done.
|
| - data.shown.push(id); |
| saveNotificationData(); |
| }, |