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

Unified Diff: lib/subscriptionClasses.js

Issue 29946572: Issue 7094 - Keep subscription filters by text only (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 19, 2018, 2:08 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
Index: lib/subscriptionClasses.js
===================================================================
--- a/lib/subscriptionClasses.js
+++ b/lib/subscriptionClasses.js
@@ -33,17 +33,16 @@
* @param {string} [title] title of the filter subscription
* @constructor
*/
function Subscription(url, title)
{
this.url = url;
this._filterText = [];
- this._filters = [];
if (title)
this._title = title;
Subscription.knownSubscriptions.set(url, this);
}
exports.Subscription = Subscription;
@@ -63,23 +62,16 @@
/**
* Filter text contained in the filter subscription.
* @type {Array.<string>}
* @private
*/
_filterText: null,
- /**
- * {@link Filter} objects corresponding to the subscription's filter text.
- * @type {Array.<Filter>}
- * @private
- */
- _filters: null,
-
_title: null,
_fixedTitle: false,
_disabled: false,
/**
* Title of the filter subscription
* @type {string}
*/
@@ -137,45 +129,36 @@
},
/**
* The number of filters in the subscription.
* @type {number}
*/
get filterCount()
{
- return this._filters.length;
+ return this._filterText.length;
},
/**
* Yields the text for each filter in the subscription.
* @yields {string}
*/
*filterText()
{
yield* this._filterText;
},
/**
- * Yields the {@link Filter} object for each filter in the subscription.
- * @yields {Filter}
- */
- *filters()
- {
- yield* this._filters;
- },
-
- /**
- * Returns the {@link Filter} object at the given 0-based index.
+ * Returns the filter text at the given 0-based index.
* @param {number} index
* @returns {?Filter}
*/
- filterAt(index)
+ filterTextAt(index)
{
- return this._filters[index] || null;
+ return this._filterText[index] || null;
},
/**
* Returns the 0-based index of the given filter.
* @param {Filter} filter
* @param {number} [fromIndex] The index from which to start the search.
* @return {number}
*/
@@ -185,52 +168,57 @@
},
/**
* Removes all filters from the subscription.
*/
clearFilters()
{
this._filterText = [];
- this._filters = [];
},
/**
* Adds a filter to the subscription.
* @param {Filter} filter
*/
addFilter(filter)
{
this._filterText.push(filter.text);
- this._filters.push(filter);
+ },
+
+ /**
+ * Adds a filter to the subscription.
+ * @param {string} filterText
+ */
+ addFilterText(filterText)
+ {
+ this._filterText.push(filterText);
},
/**
* Inserts a filter into the subscription.
* @param {Filter} filter
* @param {number} index The index at which to insert the filter.
*/
insertFilterAt(filter, index)
{
this._filterText.splice(index, 0, filter.text);
- this._filters.splice(index, 0, filter);
},
/**
* Deletes a filter from the subscription.
* @param {number} index The index at which to delete the filter.
*/
deleteFilterAt(index)
{
// Ignore index if out of bounds on the negative side, for consistency.
if (index < 0)
return;
this._filterText.splice(index, 1);
- this._filters.splice(index, 1);
},
/**
* Serializes the subscription for writing out on disk.
* @yields {string}
*/
*serialize()
{
« lib/filterStorage.js ('K') | « lib/iniParser.js ('k') | lib/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld