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: Rebased to changeset #87 Created Aug. 1, 2016, 6:10 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
@@ -337,18 +337,15 @@
function updateLanguageCollections(subscription)
{
- if (subscription.recommended == "ads")
+ if (subscription.disabled)
{
- if (subscription.disabled)
- {
- collections.allLangs.addItems(subscription);
- collections.langs.removeItem(subscription);
- }
- else
- {
- collections.allLangs.removeItem(subscription);
- collections.langs.addItems(subscription);
- }
+ collections.allLangs.addItems(subscription);
+ collections.langs.removeItem(subscription);
+ }
+ else
+ {
+ collections.allLangs.removeItem(subscription);
+ collections.langs.addItems(subscription);
}
}
@@ -376,19 +373,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)
@@ -1026,11 +1012,24 @@
function onSubscriptionMessage(action, subscription)
{
+ if (subscription.url in subscriptionsMap)
+ {
+ var knownSubscription = subscriptionsMap[subscription.url];
+ for (var property in subscription)
+ {
+ if (property == "title" && knownSubscription.recommended)
+ knownSubscription.originalTitle = subscription.title;
+ else
+ knownSubscription[property] = subscription[property];
+ }
+ subscription = knownSubscription;
+ }
switch (action)
{
case "disabled":
- subscription = updateSubscription(subscription);
- updateLanguageCollections(subscription);
+ if (subscription.recommended == "ads")
+ updateLanguageCollections(subscription);
+ updateSubscription(subscription);
break;
case "downloading":
case "downloadStatus":
@@ -1040,16 +1039,16 @@
updateSubscription(subscription);
break;
case "added":
- if (subscription.url in subscriptionsMap)
- subscription = updateSubscription(subscription);
+ if (subscription.recommended == "ads")
+ updateLanguageCollections(subscription);
+ else if (subscription.url in subscriptionsMap)
+ updateSubscription(subscription);
else
addSubscription(subscription);
collections.filterLists.addItems(subscription);
- updateLanguageCollections(subscription);
break;
case "removed":
- var knownSubscription = subscriptionsMap[subscription.url];
if (subscription.url == acceptableAdsUrl || subscription.recommended)
{
subscription.disabled = true;
@@ -1057,10 +1056,10 @@
}
else
{
- collections.custom.removeItem(knownSubscription);
+ collections.custom.removeItem(subscription);
delete subscriptionsMap[subscription.url];
}
- collections.filterLists.removeItem(knownSubscription);
+ collections.filterLists.removeItem(subscription);
break;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld