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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 function removeAntiAdblockNotification() 65 function removeAntiAdblockNotification()
66 { 66 {
67 Notification.removeNotification(notification); 67 Notification.removeNotification(notification);
68 Notification.removeQuestionListener(notification.id, notificationListener); 68 Notification.removeQuestionListener(notification.id, notificationListener);
69 } 69 }
70 70
71 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl); 71 let subscription = Subscription.fromURL(Prefs.subscriptions_antiadblockurl);
72 if (subscription.lastDownload && subscription.disabled) 72 if (subscription.lastDownload && subscription.disabled)
73 addAntiAdblockNotification(subscription); 73 addAntiAdblockNotification(subscription);
74 74
75 FilterNotifier.addListener(function(action, value, newItem, oldItem) 75 function onSubscriptionChange(subscription)
76 { 76 {
77 if (!/^subscription\.(updated|removed|disabled)$/.test(action) || value.url != Prefs.subscriptions_antiadblockurl) 77 let url = Prefs.subscriptions_antiadblockurl;
78 if (url != subscription.url)
78 return; 79 return;
79 80
80 if (action == "subscription.updated") 81 if (url in FilterStorage.knownSubscriptions && !subscription.disabled)
81 addAntiAdblockNotification(value); 82 addAntiAdblockNotification(subscription);
82 else if (action == "subscription.removed" || (action == "subscription.disabl ed" && !value.disabled)) 83 else
83 removeAntiAdblockNotification(); 84 removeAntiAdblockNotification();
84 }); 85 }
86
87 FilterNotifier.on("subscription.updated", onSubscriptionChange);
88 FilterNotifier.on("subscription.removed", onSubscriptionChange);
89 FilterNotifier.on("subscription.disabled", onSubscriptionChange);
85 } 90 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld