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

Unified Diff: new-options.js

Issue 29346555: Issue 4156 - Adblocking filter only being removed in advanced tab fix (Closed)
Patch Set: Created June 15, 2016, 5:35 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: new-options.js
===================================================================
--- a/new-options.js
+++ b/new-options.js
@@ -432,19 +432,8 @@
function updateSubscription(subscription)
{
- var knownSubscription = subscriptionsMap[subscription.url];
- for (var property in subscription)
- {
- if (property == "title" && subscription.recommended)
- knownSubscription.originalTitle = subscription.title;
- else
- knownSubscription[property] = subscription[property];
- }
-
for (var name in collections)
- collections[name].updateItem(knownSubscription);
-
- return knownSubscription;
+ collections[name].updateItem(subscription);
}
function updateFilter(filter)
@@ -929,32 +918,42 @@
function onSubscriptionMessage(action, subscription)
{
+ var knownSubscription = subscriptionsMap[subscription.url];
Thomas Greiner 2016/06/16 11:09:33 I'd prefer not having to deal with two different v
saroyanm 2016/06/16 13:35:48 Very good point!
+ if (knownSubscription)
+ {
+ for (var property in subscription)
+ {
+ if (property == "title" && knownSubscription.recommended)
+ knownSubscription.originalTitle = subscription.title;
+ else
+ knownSubscription[property] = subscription[property];
+ }
+ }
+
switch (action)
{
case "disabled":
- subscription = updateSubscription(subscription);
- updateLanguageCollections(subscription);
+ updateSubscription(knownSubscription);
+ updateLanguageCollections(knownSubscription);
break;
case "downloading":
case "downloadStatus":
case "homepage":
case "lastDownload":
case "title":
- updateSubscription(subscription);
+ updateSubscription(knownSubscription);
break;
case "added":
- if (subscription.url in subscriptionsMap)
- subscription = updateSubscription(subscription);
+ if (knownSubscription)
+ updateLanguageCollections(knownSubscription);
else
addSubscription(subscription);
- collections.filterLists.addItems(subscription);
- updateLanguageCollections(subscription);
+ subscription = updateSubscription(knownSubscription || subscription);
+ collections.filterLists.addItems(knownSubscription || subscription);
break;
case "removed":
- var knownSubscription = subscriptionsMap[subscription.url];
-
- if (subscription.url == acceptableAdsUrl || subscription.recommended)
+ if (subscription.url == acceptableAdsUrl || knownSubscription.recommended)
{
subscription.disabled = true;
onSubscriptionMessage("disabled", subscription);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld