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

Unified Diff: lib/filterStorage.js

Issue 29870577: Issue 6916 - Encapsulate filter subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Sept. 1, 2018, 4:53 a.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 | « lib/filterListener.js ('k') | lib/iniParser.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterStorage.js
===================================================================
--- a/lib/filterStorage.js
+++ b/lib/filterStorage.js
@@ -211,17 +211,17 @@
* particular group that the filter should be added to
* @param {number} [position]
* position within the subscription at which the filter should be added
*/
addFilter(filter, subscription, position)
{
if (!subscription)
{
- for (let currentSubscription of filter.subscriptions)
+ for (let currentSubscription of filter.subscriptions())
{
if (currentSubscription instanceof SpecialSubscription &&
!currentSubscription.disabled)
{
return; // No need to add
}
}
subscription = FilterStorage.getGroupForFilter(filter);
@@ -232,34 +232,34 @@
subscription = SpecialSubscription.createForFilter(filter);
this.addSubscription(subscription);
return;
}
if (typeof position == "undefined")
position = subscription.filters.length;
- filter.subscriptions.add(subscription);
+ filter.addSubscription(subscription);
subscription.filters.splice(position, 0, filter);
filterNotifier.emit("filter.added", filter, subscription, position);
},
/**
* Removes a user-defined filter from the list
* @param {Filter} filter
* @param {SpecialSubscription} [subscription] a particular filter group that
* the filter should be removed from (if ommited will be removed from all
* subscriptions)
* @param {number} [position] position inside the filter group at which the
* filter should be removed (if ommited all instances will be removed)
*/
removeFilter(filter, subscription, position)
{
let subscriptions = (
- subscription ? [subscription] : filter.subscriptions
+ subscription ? [subscription] : filter.subscriptions()
);
for (let currentSubscription of subscriptions)
{
if (currentSubscription instanceof SpecialSubscription)
{
let positions = [];
if (typeof position == "undefined")
{
@@ -276,17 +276,17 @@
for (let j = positions.length - 1; j >= 0; j--)
{
let currentPosition = positions[j];
if (currentSubscription.filters[currentPosition] == filter)
{
currentSubscription.filters.splice(currentPosition, 1);
if (currentSubscription.filters.indexOf(filter) < 0)
- filter.subscriptions.delete(currentSubscription);
+ filter.removeSubscription(currentSubscription);
filterNotifier.emit("filter.removed", filter, currentSubscription,
currentPosition);
}
}
}
}
},
@@ -658,24 +658,24 @@
* filter subscription that should be connected to its filters
*/
function addSubscriptionFilters(subscription)
{
if (!FilterStorage.knownSubscriptions.has(subscription.url))
return;
for (let filter of subscription.filters)
- filter.subscriptions.add(subscription);
+ filter.addSubscription(subscription);
}
/**
* Removes subscription's filters from the subscription without any
* notifications.
* @param {Subscription} subscription filter subscription to be removed
*/
function removeSubscriptionFilters(subscription)
{
if (!FilterStorage.knownSubscriptions.has(subscription.url))
return;
for (let filter of subscription.filters)
- filter.subscriptions.delete(subscription);
+ filter.removeSubscription(subscription);
}
« no previous file with comments | « lib/filterListener.js ('k') | lib/iniParser.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld