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

Side by Side Diff: desktop-options.js

Issue 29615620: issue 6075 - Hide Acceptable Ads notification when corresponding subscription is removed (Closed)
Patch Set: Created Nov. 22, 2017, 1:27 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 acceptableAdsPrivacy.setAttribute("aria-disabled", true); 1094 acceptableAdsPrivacy.setAttribute("aria-disabled", true);
1095 acceptableAdsPrivacy.setAttribute("tabindex", -1); 1095 acceptableAdsPrivacy.setAttribute("tabindex", -1);
1096 } 1096 }
1097 } 1097 }
1098 1098
1099 function isAcceptableAds(url) 1099 function isAcceptableAds(url)
1100 { 1100 {
1101 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1101 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1102 } 1102 }
1103 1103
1104 function isConflictingSubscription(subscription)
1105 {
1106 return subscription.url == acceptableAdsUrl ||
Thomas Greiner 2017/11/23 14:46:12 Suggestion: If you want you can pass an optional `
saroyanm 2017/11/23 16:41:37 Not sure if it will help much and it might complic
1107 subscription.recommended == "privacy"
1108 }
1109
1104 function hasPrivacyConflict() 1110 function hasPrivacyConflict()
Thomas Greiner 2017/11/23 14:46:12 I wouldn't mind keeping the privacy conflict check
saroyanm 2017/11/23 16:41:37 Agree, done.
1105 { 1111 {
1106 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; 1112 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl];
1107 let privacyList = null; 1113 let privacyList = null;
1108 for (let url in subscriptionsMap) 1114 for (let url in subscriptionsMap)
1109 { 1115 {
1110 let subscription = subscriptionsMap[url]; 1116 let subscription = subscriptionsMap[url];
1111 if (subscription.recommended == "privacy") 1117 if (subscription.recommended == "privacy")
1112 { 1118 {
1113 privacyList = subscription; 1119 privacyList = subscription;
1114 break; 1120 break;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 return; 1290 return;
1285 } 1291 }
1286 else if (url in subscriptionsMap) 1292 else if (url in subscriptionsMap)
1287 updateSubscription(subscription); 1293 updateSubscription(subscription);
1288 else 1294 else
1289 addSubscription(subscription); 1295 addSubscription(subscription);
1290 1296
1291 if (isAcceptableAds(url)) 1297 if (isAcceptableAds(url))
1292 setAcceptableAds(); 1298 setAcceptableAds();
1293 1299
1294 if ((url == acceptableAdsUrl || recommended == "privacy") && 1300 if (isConflictingSubscription(subscription) && hasPrivacyConflict())
1295 hasPrivacyConflict())
1296 { 1301 {
1297 getPref("ui_warn_tracking", (showTrackingWarning) => 1302 getPref("ui_warn_tracking", (showTrackingWarning) =>
1298 { 1303 {
1299 if (showTrackingWarning) 1304 if (showTrackingWarning)
1300 E("acceptable-ads").classList.add("show-warning"); 1305 E("acceptable-ads").classList.add("show-warning");
1301 }); 1306 });
1302 } 1307 }
1303 1308
1304 collections.filterLists.addItem(subscription); 1309 collections.filterLists.addItem(subscription);
1305 break; 1310 break;
1306 case "removed": 1311 case "removed":
Thomas Greiner 2017/11/23 12:53:39 It's a shame we missed that in our last review so
saroyanm 2017/11/23 14:06:51 Right.
1307 if (subscription.recommended) 1312 if (subscription.recommended)
1308 { 1313 {
1309 subscription.disabled = true; 1314 subscription.disabled = true;
1310 onSubscriptionMessage("disabled", subscription); 1315 onSubscriptionMessage("disabled", subscription);
1311 } 1316 }
1312 else 1317 else
1313 { 1318 {
1314 delete subscriptionsMap[subscription.url]; 1319 delete subscriptionsMap[subscription.url];
1315 if (isAcceptableAds(subscription.url)) 1320 if (isAcceptableAds(subscription.url))
1316 { 1321 {
1317 setAcceptableAds(); 1322 setAcceptableAds();
1318 } 1323 }
1319 else 1324 else
1320 { 1325 {
1321 collections.more.removeItem(subscription); 1326 collections.more.removeItem(subscription);
1322 } 1327 }
1323 } 1328 }
1329 if (isConflictingSubscription(subscription))
1330 {
1331 E("acceptable-ads").classList.remove("show-warning");
1332 }
Thomas Greiner 2017/11/23 12:53:39 Why not instead introduce a function similar to `s
saroyanm 2017/11/23 14:06:51 Good point, done.
1333
1324 collections.filterLists.removeItem(subscription); 1334 collections.filterLists.removeItem(subscription);
1325 break; 1335 break;
1326 } 1336 }
1327 } 1337 }
1328 1338
1329 function hidePref(key, value) 1339 function hidePref(key, value)
1330 { 1340 {
1331 let element = document.querySelector("[data-pref='" + key + "']"); 1341 let element = document.querySelector("[data-pref='" + key + "']");
1332 if (element) 1342 if (element)
1333 element.setAttribute("aria-hidden", value); 1343 element.setAttribute("aria-hidden", value);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 }); 1468 });
1459 browser.runtime.sendMessage({ 1469 browser.runtime.sendMessage({
1460 type: "subscriptions.listen", 1470 type: "subscriptions.listen",
1461 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1471 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1462 "title", "downloadStatus", "downloading"] 1472 "title", "downloadStatus", "downloading"]
1463 }); 1473 });
1464 1474
1465 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1475 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1466 window.addEventListener("hashchange", onHashChange, false); 1476 window.addEventListener("hashchange", onHashChange, false);
1467 } 1477 }
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