Index: lib/notification.js |
=================================================================== |
--- a/lib/notification.js |
+++ b/lib/notification.js |
@@ -191,9 +191,12 @@ |
let notificationToShow = null; |
for (let notification of notifications) |
{ |
- if ((typeof notification.type === "undefined" || notification.type !== "critical") |
- && Prefs.notificationdata.shown.indexOf(notification.id) !== -1) |
- continue; |
+ if (typeof notification.type === "undefined" || notification.type !== "critical") |
+ { |
+ if (Prefs.notificationdata.shown.indexOf(notification.id) !== -1 |
+ || Prefs.notifications_ignoredcategories.indexOf("*") !== -1) |
+ continue; |
+ } |
if (typeof url === "string" || notification.urlFilters instanceof Array) |
{ |
@@ -332,6 +335,27 @@ |
let questionListeners = listeners[id]; |
for (let listener of questionListeners) |
listener(approved); |
+ }, |
+ |
+ /** |
+ * Toggles whether notifications of a specific category should be ignored |
+ * @param {String} category notification category identifier |
+ * @param {Boolean} [forceValue] force specified value |
+ */ |
+ toggleIgnoreCategory: function(category, forceValue) |
+ { |
+ let categories = Prefs.notifications_ignoredcategories; |
+ let index = categories.indexOf(category); |
+ if (index == -1 && forceValue !== false) |
+ { |
+ categories.push(category); |
+ Prefs.notifications_showui = true; |
+ } |
+ else if (index != -1 && forceValue !== true) |
+ categories.splice(index, 1); |
+ |
+ // HACK: JSON values aren't saved unless they are assigned a different object. |
+ Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories)); |
} |
}; |
Notification.init(); |