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

Unified Diff: lib/filterStorage.js

Issue 29868577: Issue 6891 - Rename FilterNotifier to filterNotifier (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 29, 2018, 2 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 | « lib/filterNotifier.js ('k') | lib/subscriptionClasses.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
@@ -22,17 +22,17 @@
* subscriptions and filters.
*/
const {IO} = require("io");
const {Prefs} = require("prefs");
const {Filter, ActiveFilter} = require("./filterClasses");
const {Subscription, SpecialSubscription,
ExternalSubscription} = require("./subscriptionClasses");
-const {FilterNotifier} = require("./filterNotifier");
+const {filterNotifier} = require("./filterNotifier");
const {INIParser} = require("./iniParser");
/**
* Version number of the filter storage file format.
* @type {number}
*/
let formatVersion = 5;
@@ -127,17 +127,17 @@
{
if (FilterStorage.knownSubscriptions.has(subscription.url))
return;
FilterStorage.subscriptions.push(subscription);
FilterStorage.knownSubscriptions.set(subscription.url, subscription);
addSubscriptionFilters(subscription);
- FilterNotifier.emit("subscription.added", subscription);
+ filterNotifier.emit("subscription.added", subscription);
},
/**
* Removes a filter subscription from the list
* @param {Subscription} subscription filter subscription to be removed
*/
removeSubscription(subscription)
{
@@ -149,17 +149,17 @@
FilterStorage.subscriptions.splice(i--, 1);
FilterStorage.knownSubscriptions.delete(subscription.url);
// This should be the last remaining reference to the Subscription
// object.
Subscription.knownSubscriptions.delete(subscription.url);
- FilterNotifier.emit("subscription.removed", subscription);
+ filterNotifier.emit("subscription.removed", subscription);
return;
}
}
},
/**
* Moves a subscription in the list to a new position.
* @param {Subscription} subscription filter subscription to be moved
@@ -181,31 +181,31 @@
if (currentPos < newPos)
newPos--;
if (currentPos == newPos)
return;
FilterStorage.subscriptions.splice(currentPos, 1);
FilterStorage.subscriptions.splice(newPos, 0, subscription);
- FilterNotifier.emit("subscription.moved", subscription);
+ filterNotifier.emit("subscription.moved", subscription);
},
/**
* Replaces the list of filters in a subscription by a new list
* @param {Subscription} subscription filter subscription to be updated
* @param {Filter[]} filters new filter list
*/
updateSubscriptionFilters(subscription, filters)
{
removeSubscriptionFilters(subscription);
subscription.oldFilters = subscription.filters;
subscription.filters = filters;
addSubscriptionFilters(subscription);
- FilterNotifier.emit("subscription.updated", subscription);
+ filterNotifier.emit("subscription.updated", subscription);
delete subscription.oldFilters;
},
/**
* Adds a user-defined filter to the list
* @param {Filter} filter
* @param {SpecialSubscription} [subscription]
* particular group that the filter should be added to
@@ -234,17 +234,17 @@
return;
}
if (typeof position == "undefined")
position = subscription.filters.length;
filter.subscriptions.add(subscription);
subscription.filters.splice(position, 0, filter);
- FilterNotifier.emit("filter.added", filter, subscription, position);
+ 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)
@@ -277,17 +277,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);
- FilterNotifier.emit("filter.removed", filter, currentSubscription,
+ filterNotifier.emit("filter.removed", filter, currentSubscription,
currentPosition);
}
}
}
}
},
/**
@@ -308,17 +308,17 @@
newPosition = Math.min(Math.max(newPosition, 0),
subscription.filters.length - 1);
if (oldPosition == newPosition)
return;
subscription.filters.splice(oldPosition, 1);
subscription.filters.splice(newPosition, 0, filter);
- FilterNotifier.emit("filter.moved", filter, subscription, oldPosition,
+ filterNotifier.emit("filter.moved", filter, subscription, oldPosition,
newPosition);
},
/**
* Increases the hit count for a filter by one
* @param {Filter} filter
*/
increaseHitCount(filter)
@@ -375,17 +375,17 @@
this.fileProperties = parser.fileProperties;
this.subscriptions = parser.subscriptions;
this.knownSubscriptions = knownSubscriptions;
Filter.knownFilters = parser.knownFilters;
Subscription.knownSubscriptions = parser.knownSubscriptions;
if (!silent)
- FilterNotifier.emit("load");
+ filterNotifier.emit("load");
}
};
},
/**
* Loads all subscriptions from the disk.
* @return {Promise} promise resolved or rejected when loading is complete
*/
@@ -423,17 +423,17 @@
});
}).catch(error =>
{
Cu.reportError(error);
return tryBackup(1);
}).then(() =>
{
this.initialized = true;
- FilterNotifier.emit("load");
+ filterNotifier.emit("load");
});
},
/**
* Constructs the file name for a patterns.ini backup.
* @param {number} backupIndex
* number of the backup file (1 being the most recent)
* @return {string} backup file name
@@ -591,17 +591,17 @@
{
// Errors during backup creation shouldn't prevent writing filters.
Cu.reportError(error);
}).then(() =>
{
return IO.writeToFile(this.sourceFile, this.exportData());
}).then(() =>
{
- FilterNotifier.emit("save");
+ filterNotifier.emit("save");
}).catch(error =>
{
// If saving failed, report error but continue - we still have to process
// flags.
Cu.reportError(error);
}).then(() =>
{
this._saving = false;
« no previous file with comments | « lib/filterNotifier.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld