[Pkg-mozext-commits] [adblock-plus] 19/74: Issue 2192 - Added notification opt-out mechanism

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 12:07:06 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 67100038ba35c954781136bd58c665f3322f82af
Author: Thomas Greiner <thomas at adblockplus.org>
Date:   Wed May 27 13:49:26 2015 +0200

    Issue 2192 - Added notification opt-out mechanism
---
 defaults/prefs.json |  4 +++-
 lib/notification.js | 30 +++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/defaults/prefs.json b/defaults/prefs.json
index e179430..3ee6f98 100644
--- a/defaults/prefs.json
+++ b/defaults/prefs.json
@@ -36,7 +36,9 @@
     "notificationdata": {},
     "subscriptions_antiadblockurl": "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt",
     "please_kill_startup_performance": false,
-    "suppress_first_run_page": false
+    "suppress_first_run_page": false,
+    "notifications_showui": false,
+    "notifications_ignoredcategories": []
   },
   "preconfigurable": ["suppress_first_run_page"]
 }
diff --git a/lib/notification.js b/lib/notification.js
index dc1e98b..acb41b9 100644
--- a/lib/notification.js
+++ b/lib/notification.js
@@ -191,9 +191,12 @@ let Notification = exports.Notification =
     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 Notification = exports.Notification =
     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();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list