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

Delta Between Two Patch Sets: js/desktop-options.js

Issue 29712599: Issue 6420 - Fixed poping up whitelisted website notification for several custom filter lists (Closed)
Left Patch Set: Created March 1, 2018, 12:13 p.m.
Right Patch Set: Created March 5, 2018, 8:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« ext/content.js ('K') | « ext/content.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 461
462 filtersMap[filter.text] = filter; 462 filtersMap[filter.text] = filter;
463 } 463 }
464 464
465 function loadCustomFilters(filters) 465 function loadCustomFilters(filters)
466 { 466 {
467 for (let filter of filters) 467 for (let filter of filters)
468 updateFilter(filter); 468 updateFilter(filter);
469 469
470 setCustomFiltersView("read"); 470 setCustomFiltersView("read");
471 isCustomFiltersLoaded = true;
472 } 471 }
473 472
474 function removeCustomFilter(text) 473 function removeCustomFilter(text)
475 { 474 {
476 let index = customFilters.indexOf(text); 475 let index = customFilters.indexOf(text);
477 if (index >= 0) 476 if (index >= 0)
478 customFilters.splice(index, 1); 477 customFilters.splice(index, 1);
479 478
480 updateCustomFiltersUi(); 479 updateCustomFiltersUi();
481 } 480 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 for (let property in collections) 1139 for (let property in collections)
1141 collections[property].clearAll(); 1140 collections[property].clearAll();
1142 1141
1143 setCustomFiltersView("empty"); 1142 setCustomFiltersView("empty");
1144 browser.runtime.sendMessage({ 1143 browser.runtime.sendMessage({
1145 type: "subscriptions.get", 1144 type: "subscriptions.get",
1146 special: true 1145 special: true
1147 }, 1146 },
1148 (subscriptions) => 1147 (subscriptions) =>
1149 { 1148 {
1150 // Load filters 1149 let customFilterPromises = subscriptions.map(getSubscriptionFilters);
1151 for (let subscription of subscriptions) 1150 Promise.all(customFilterPromises).then((filters) =>
1152 { 1151 {
1153 browser.runtime.sendMessage({ 1152 loadCustomFilters([].concat(...filters));
1154 type: "filters.get", 1153 isCustomFiltersLoaded = true;
1155 subscriptionUrl: subscription.url 1154 });
1156 },
1157 (filters) =>
1158 {
1159 // Reset each time as there might be several custom filters
1160 if (isCustomFiltersLoaded)
1161 isCustomFiltersLoaded = false;
Thomas Greiner 2018/03/02 11:43:57 Why not instead just move `isCustomFiltersLoaded =
saroyanm 2018/03/02 15:59:14 Agree, done.
Thomas Greiner 2018/03/02 16:40:43 What about the code you initially added?
saroyanm 2018/03/02 16:43:46 Which code ?
Thomas Greiner 2018/03/02 17:09:04 The new code from the first patch set.
saroyanm 2018/03/02 17:16:51 You mean the current one, right ? I don't remember
Thomas Greiner 2018/03/02 17:24:16 I mean this one: https://codereview.adblockplus.or
saroyanm 2018/03/05 12:14:52 We are using loop on top, but now we decided to re
saroyanm 2018/03/05 14:52:27 Done.
1162 loadCustomFilters(filters);
1163 });
1164 }
1165 }); 1155 });
1166 loadRecommendations(); 1156 loadRecommendations();
1167 browser.runtime.sendMessage({ 1157 browser.runtime.sendMessage({
1168 type: "prefs.get", 1158 type: "prefs.get",
1169 key: "subscriptions_exceptionsurl" 1159 key: "subscriptions_exceptionsurl"
1170 }, 1160 },
1171 (url) => 1161 (url) =>
1172 { 1162 {
1173 acceptableAdsUrl = url; 1163 acceptableAdsUrl = url;
1174 1164
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 else 1319 else
1330 { 1320 {
1331 collections.more.removeItem(subscription); 1321 collections.more.removeItem(subscription);
1332 } 1322 }
1333 } 1323 }
1334 1324
1335 collections.filterLists.removeItem(subscription); 1325 collections.filterLists.removeItem(subscription);
1336 setPrivacyConflict(); 1326 setPrivacyConflict();
1337 break; 1327 break;
1338 } 1328 }
1329 }
1330
1331 function getSubscriptionFilters(subscription)
1332 {
1333 return browser.runtime.sendMessage({
1334 type: "filters.get",
1335 subscriptionUrl: subscription.url});
1339 } 1336 }
1340 1337
1341 function hidePref(key, value) 1338 function hidePref(key, value)
1342 { 1339 {
1343 let element = document.querySelector("[data-pref='" + key + "']"); 1340 let element = document.querySelector("[data-pref='" + key + "']");
1344 if (element) 1341 if (element)
1345 element.setAttribute("aria-hidden", value); 1342 element.setAttribute("aria-hidden", value);
1346 } 1343 }
1347 1344
1348 function getPref(key, callback) 1345 function getPref(key, callback)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 "ui_warn_tracking"] 1465 "ui_warn_tracking"]
1469 }); 1466 });
1470 browser.runtime.sendMessage({ 1467 browser.runtime.sendMessage({
1471 type: "subscriptions.listen", 1468 type: "subscriptions.listen",
1472 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1473 "title", "downloadStatus", "downloading"] 1470 "title", "downloadStatus", "downloading"]
1474 }); 1471 });
1475 1472
1476 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1477 window.addEventListener("hashchange", onHashChange, false); 1474 window.addEventListener("hashchange", onHashChange, false);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld