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

Side by Side Diff: new-options.js

Issue 29346555: Issue 4156 - Adblocking filter only being removed in advanced tab fix (Closed)
Patch Set: Implementation simplification Created June 16, 2016, 1:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 else 425 else
426 collection = collections.custom; 426 collection = collections.custom;
427 427
428 collection.addItems(subscription); 428 collection.addItems(subscription);
429 subscriptionsMap[subscription.url] = subscription; 429 subscriptionsMap[subscription.url] = subscription;
430 updateTooltips(); 430 updateTooltips();
431 } 431 }
432 432
433 function updateSubscription(subscription) 433 function updateSubscription(subscription)
434 { 434 {
435 var knownSubscription = subscriptionsMap[subscription.url];
436 for (var property in subscription)
437 {
438 if (property == "title" && subscription.recommended)
439 knownSubscription.originalTitle = subscription.title;
440 else
441 knownSubscription[property] = subscription[property];
442 }
443
444 for (var name in collections) 435 for (var name in collections)
445 collections[name].updateItem(knownSubscription); 436 collections[name].updateItem(subscription);
446
447 return knownSubscription;
448 } 437 }
449 438
450 function updateFilter(filter) 439 function updateFilter(filter)
451 { 440 {
452 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); 441 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/);
453 if (match && !filtersMap[filter.text]) 442 if (match && !filtersMap[filter.text])
454 { 443 {
455 filter.title = match[1]; 444 filter.title = match[1];
456 collections.whitelist.addItems(filter); 445 collections.whitelist.addItems(filter);
457 } 446 }
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 collections.whitelist.removeItem(knownFilter); 911 collections.whitelist.removeItem(knownFilter);
923 collections.customFilters.removeItem(knownFilter); 912 collections.customFilters.removeItem(knownFilter);
924 delete filtersMap[filter.text]; 913 delete filtersMap[filter.text];
925 updateShareLink(); 914 updateShareLink();
926 break; 915 break;
927 } 916 }
928 } 917 }
929 918
930 function onSubscriptionMessage(action, subscription) 919 function onSubscriptionMessage(action, subscription)
931 { 920 {
921 if (subscription.url in subscriptionsMap)
922 {
923 var knownSubscription = subscriptionsMap[subscription.url];
924 for (var property in subscription)
925 {
926 if (property == "title" && knownSubscription.recommended)
927 knownSubscription.originalTitle = subscription.title;
928 else
929 knownSubscription[property] = subscription[property];
930 }
931 subscription = knownSubscription;
932 }
932 switch (action) 933 switch (action)
933 { 934 {
934 case "disabled": 935 case "disabled":
935 subscription = updateSubscription(subscription); 936 updateSubscription(subscription);
936 updateLanguageCollections(subscription); 937 updateLanguageCollections(subscription);
937 break; 938 break;
938 case "downloading": 939 case "downloading":
939 case "downloadStatus": 940 case "downloadStatus":
940 case "homepage": 941 case "homepage":
941 case "lastDownload": 942 case "lastDownload":
942 case "title": 943 case "title":
943 updateSubscription(subscription); 944 updateSubscription(subscription);
944 break; 945 break;
945 case "added": 946 case "added":
946 if (subscription.url in subscriptionsMap) 947 if (subscription)
Thomas Greiner 2016/06/16 16:10:34 This will always be `true`. Compare it with the ba
saroyanm 2016/06/16 16:51:44 Well spotted, thanks, Done.
947 subscription = updateSubscription(subscription); 948 updateLanguageCollections(subscription);
948 else 949 else
949 addSubscription(subscription); 950 addSubscription(subscription);
950 951
952 updateSubscription(subscription);
Thomas Greiner 2016/06/16 16:10:34 I noticed that those two function calls swapped pl
saroyanm 2016/06/16 16:51:44 Logic here is bit confusing and yes swiping the fu
951 collections.filterLists.addItems(subscription); 953 collections.filterLists.addItems(subscription);
952 updateLanguageCollections(subscription);
953 break; 954 break;
954 case "removed": 955 case "removed":
955 var knownSubscription = subscriptionsMap[subscription.url];
956
957 if (subscription.url == acceptableAdsUrl || subscription.recommended) 956 if (subscription.url == acceptableAdsUrl || subscription.recommended)
958 { 957 {
959 subscription.disabled = true; 958 subscription.disabled = true;
960 onSubscriptionMessage("disabled", subscription); 959 onSubscriptionMessage("disabled", subscription);
961 } 960 }
962 else 961 else
963 { 962 {
964 collections.custom.removeItem(knownSubscription); 963 collections.custom.removeItem(subscription);
965 delete subscriptionsMap[subscription.url]; 964 delete subscriptionsMap[subscription.url];
966 } 965 }
967 collections.filterLists.removeItem(knownSubscription); 966 collections.filterLists.removeItem(subscription);
968 break; 967 break;
969 } 968 }
970 969
971 updateShareLink(); 970 updateShareLink();
972 } 971 }
973 972
974 function hidePref(key, value) 973 function hidePref(key, value)
975 { 974 {
976 var element = document.querySelector("[data-pref='" + key + "']"); 975 var element = document.querySelector("[data-pref='" + key + "']");
977 if (element) 976 if (element)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 }); 1197 });
1199 ext.backgroundPage.sendMessage( 1198 ext.backgroundPage.sendMessage(
1200 { 1199 {
1201 type: "subscriptions.listen", 1200 type: "subscriptions.listen",
1202 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1201 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1203 "title", "downloadStatus", "downloading"] 1202 "title", "downloadStatus", "downloading"]
1204 }); 1203 });
1205 1204
1206 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1205 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1207 })(); 1206 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld