Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/antiadblockInit.js

Issue 29338973: Issue 3862 - Make antiadblockInit use the new FilterNotifier API (Closed)
Patch Set: Created March 23, 2016, 2:34 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/antiadblockInit.js
===================================================================
--- a/lib/antiadblockInit.js
+++ b/lib/antiadblockInit.js
@@ -72,14 +72,19 @@
if (subscription.lastDownload && subscription.disabled)
addAntiAdblockNotification(subscription);
- FilterNotifier.addListener(function(action, value, newItem, oldItem)
+ function onSubscriptionChange(subscription)
{
- if (!/^subscription\.(updated|removed|disabled)$/.test(action) || value.url != Prefs.subscriptions_antiadblockurl)
+ let url = Prefs.subscriptions_antiadblockurl;
+ if (url != subscription.url)
return;
- if (action == "subscription.updated")
- addAntiAdblockNotification(value);
- else if (action == "subscription.removed" || (action == "subscription.disabled" && !value.disabled))
+ if (url in FilterStorage.knownSubscriptions && !subscription.disabled)
+ addAntiAdblockNotification(subscription);
+ else
removeAntiAdblockNotification();
- });
+ }
+
+ FilterNotifier.on("subscription.updated", onSubscriptionChange);
+ FilterNotifier.on("subscription.removed", onSubscriptionChange);
+ FilterNotifier.on("subscription.disabled", onSubscriptionChange);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld