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

Unified Diff: lib/sync.js

Issue 6341149593698304: Issue 301 - Change for each to for .. of .. in lib/ (Closed)
Patch Set: Created April 10, 2014, 5:02 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/subscriptionClasses.js ('k') | lib/synchronizer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/sync.js
===================================================================
--- a/lib/sync.js
+++ b/lib/sync.js
@@ -193,30 +193,30 @@ ABPStore.prototype =
{
let record = new ABPEngine.prototype._recordObj(collection, id);
if (id == filtersRecordID)
{
record.cleartext = {
id: id,
subscriptions: [],
};
- for each (let subscription in FilterStorage.subscriptions)
+ for (let subscription of FilterStorage.subscriptions)
{
if (subscription instanceof ExternalSubscription)
continue;
let subscriptionEntry =
{
url: subscription.url,
disabled: subscription.disabled
};
if (subscription instanceof SpecialSubscription)
{
subscriptionEntry.filters = [];
- for each (let filter in subscription.filters)
+ for (let filter of subscription.filters)
{
let filterEntry = {text: filter.text};
if (filter instanceof ActiveFilter)
filterEntry.disabled = filter.disabled;
subscriptionEntry.filters.push(filterEntry);
}
}
else
@@ -246,17 +246,17 @@ ABPStore.prototype =
return;
this._log.trace("Merging in remote data");
let data = record.cleartext.subscriptions;
// First make sure we have the same subscriptions on both sides
let seenSubscription = {__proto__: null};
- for each (let remoteSubscription in data)
+ for (let remoteSubscription of data)
{
seenSubscription[remoteSubscription.url] = true;
if (remoteSubscription.url in FilterStorage.knownSubscriptions)
{
let subscription = FilterStorage.knownSubscriptions[remoteSubscription.url];
if (!trackerInstance.didSubscriptionChange(remoteSubscription))
{
// Only change local subscription if there were no changes, otherwise dismiss remote changes
@@ -277,33 +277,33 @@ ABPStore.prototype =
{
subscription.title = remoteSubscription.title;
FilterStorage.addSubscription(subscription);
Synchronizer.execute(subscription);
}
}
}
- for each (let subscription in FilterStorage.subscriptions.slice())
+ for (let subscription of FilterStorage.subscriptions.slice())
{
if (!(subscription.url in seenSubscription) && subscription instanceof DownloadableSubscription && !trackerInstance.didSubscriptionChange(subscription))
{
// Subscription was removed remotely, remove it locally as well
FilterStorage.removeSubscription(subscription);
}
}
// Now sync the custom filters
let seenFilter = {__proto__: null};
- for each (let remoteSubscription in data)
+ for (let remoteSubscription of data)
{
if (!("filters" in remoteSubscription))
continue;
- for each (let remoteFilter in remoteSubscription.filters)
+ for (let remoteFilter of remoteSubscription.filters)
{
seenFilter[remoteFilter.text] = true;
let filter = Filter.fromText(remoteFilter.text);
if (trackerInstance.didFilterChange(filter))
continue;
if (filter.subscriptions.some(function(subscription) subscription instanceof SpecialSubscription))
@@ -315,22 +315,22 @@ ABPStore.prototype =
else
{
// Filter was added remotely, add it locally as well
FilterStorage.addFilter(filter);
}
}
}
- for each (let subscription in FilterStorage.subscriptions)
+ for (let subscription of FilterStorage.subscriptions)
{
if (!(subscription instanceof SpecialSubscription))
continue;
- for each (let filter in subscription.filters.slice())
+ for (let filter of subscription.filters.slice())
{
if (!(filter.text in seenFilter) && !trackerInstance.didFilterChange(filter))
{
// Filter was removed remotely, remove it locally as well
FilterStorage.removeFilter(filter);
}
}
}
@@ -343,23 +343,23 @@ ABPStore.prototype =
{
// Shouldn't be called but if it is - ignore
},
wipe: function()
{
this._log.trace("Got wipe command, removing all data");
- for each (let subscription in FilterStorage.subscriptions.slice())
+ for (let subscription of FilterStorage.subscriptions.slice())
{
if (subscription instanceof DownloadableSubscription)
FilterStorage.removeSubscription(subscription);
else if (subscription instanceof SpecialSubscription)
{
- for each (let filter in subscription.filters.slice())
+ for (let filter of subscription.filters.slice())
FilterStorage.removeFilter(filter);
}
}
// Data wiped, forget about local changes now
trackerInstance.clearPrivateChanges()
}
};
@@ -430,19 +430,19 @@ ABPTracker.prototype =
{
// Subscription moved to a new address
this.addPrivateChange("subscription " + item.url);
this.addPrivateChange("subscription " + item.oldSubscription.url);
}
else if (item instanceof SpecialSubscription)
{
// User's filters changed via Preferences window
- for each (let filter in item.filters)
+ for (let filter of item.filters)
this.addPrivateChange("filter " + filter.text);
- for each (let filter in item.oldFilters)
+ for (let filter of item.oldFilters)
this.addPrivateChange("filter " + filter.text);
}
break;
case "subscription.added":
case "subscription.removed":
case "subscription.disabled":
case "subscription.title":
this.addPrivateChange("subscription " + item.url);
« no previous file with comments | « lib/subscriptionClasses.js ('k') | lib/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld