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

Unified Diff: lib/filterListener.js

Issue 29946572: Issue 7094 - Keep subscription filters by text only (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Fix bug Created Nov. 19, 2018, 2:28 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 | « no previous file | lib/filterStorage.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterListener.js
===================================================================
--- a/lib/filterListener.js
+++ b/lib/filterListener.js
@@ -27,17 +27,17 @@
const {filterStorage} = require("./filterStorage");
const {filterNotifier} = require("./filterNotifier");
const {ElemHide} = require("./elemHide");
const {ElemHideEmulation} = require("./elemHideEmulation");
const {ElemHideExceptions} = require("./elemHideExceptions");
const {Snippets} = require("./snippets");
const {defaultMatcher} = require("./matcher");
-const {ActiveFilter, RegExpFilter,
+const {Filter, ActiveFilter, RegExpFilter,
ElemHideBase, ElemHideFilter, ElemHideEmulationFilter,
SnippetFilter} = require("./filterClasses");
const {SpecialSubscription} = require("./subscriptionClasses");
const {Prefs} = require("prefs");
/**
* Increases on filter changes, filters will be saved if it exceeds 1.
* @type {number}
@@ -234,65 +234,69 @@
let current = (Math.random() * len) | 0;
let step;
do
{
step = primes[(Math.random() * primes.length) | 0];
} while (len % step == 0);
for (let i = 0; i < len; i++, current = (current + step) % len)
- addFilter(subscription.filterAt(current));
+ {
+ let filter = Filter.fromText(subscription.filterTextAt(current));
+ filter.addSubscription(subscription);
Manish Jethani 2018/11/19 02:29:44 This was the bug. The filters did not belong to an
+ addFilter(filter);
+ }
}
function onSubscriptionAdded(subscription)
{
FilterListener.setDirty(1);
if (!subscription.disabled)
addSubscriptionFilters(subscription);
}
function onSubscriptionRemoved(subscription)
{
FilterListener.setDirty(1);
if (!subscription.disabled)
{
- for (let filter of subscription.filters())
- removeFilter(filter);
+ for (let text of subscription.filterText())
+ removeFilter(Filter.fromText(text));
}
}
function onSubscriptionDisabled(subscription, newValue)
{
FilterListener.setDirty(1);
if (filterStorage.knownSubscriptions.has(subscription.url))
{
if (newValue == false)
{
addSubscriptionFilters(subscription);
}
else
{
- for (let filter of subscription.filters())
- removeFilter(filter);
+ for (let text of subscription.filterText())
+ removeFilter(Filter.fromText(text));
}
}
}
-function onSubscriptionUpdated(subscription, oldFilters)
+function onSubscriptionUpdated(subscription, oldFilterText)
{
FilterListener.setDirty(1);
if (!subscription.disabled &&
filterStorage.knownSubscriptions.has(subscription.url))
{
- for (let filter of oldFilters)
- removeFilter(filter);
+ for (let text of oldFilterText)
+ removeFilter(Filter.fromText(text));
addSubscriptionFilters(subscription);
}
}
function onFilterHitCount(filter, newValue)
{
if (newValue == 0)
« no previous file with comments | « no previous file | lib/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld