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

Side by Side Diff: js/desktop-options.js

Issue 29712599: Issue 6420 - Fixed poping up whitelisted website notification for several custom filter lists (Closed)
Patch Set: Updated as discussed with Thomas Created March 5, 2018, 2:48 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 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((subscription) =>
1151 for (let subscription of subscriptions) 1150 getSubscriptionFilters(subscription));
Thomas Greiner 2018/03/05 16:43:33 Detail: This arrow function is redundant because y
saroyanm 2018/03/05 16:51:13 I like this, will change.
1151
1152 Promise.all(customFilterPromises).then((filters) =>
1152 { 1153 {
1153 browser.runtime.sendMessage({ 1154 loadCustomFilters([].concat(...filters));
Thomas Greiner 2018/03/05 16:43:33 What is this concatenation for?
saroyanm 2018/03/05 16:51:13 It's for flattening the array. Promise.all return
Thomas Greiner 2018/03/06 13:08:47 Sorry, I missed that. Maybe because I'm used to wr
1154 type: "filters.get", 1155 isCustomFiltersLoaded = true;
1155 subscriptionUrl: subscription.url 1156 });
1156 },
1157 (filters) =>
1158 {
1159 loadCustomFilters(filters);
1160 });
1161 }
1162 }); 1157 });
1163 loadRecommendations(); 1158 loadRecommendations();
1164 browser.runtime.sendMessage({ 1159 browser.runtime.sendMessage({
1165 type: "prefs.get", 1160 type: "prefs.get",
1166 key: "subscriptions_exceptionsurl" 1161 key: "subscriptions_exceptionsurl"
1167 }, 1162 },
1168 (url) => 1163 (url) =>
1169 { 1164 {
1170 acceptableAdsUrl = url; 1165 acceptableAdsUrl = url;
1171 1166
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 collections.more.removeItem(subscription); 1323 collections.more.removeItem(subscription);
1329 } 1324 }
1330 } 1325 }
1331 1326
1332 collections.filterLists.removeItem(subscription); 1327 collections.filterLists.removeItem(subscription);
1333 setPrivacyConflict(); 1328 setPrivacyConflict();
1334 break; 1329 break;
1335 } 1330 }
1336 } 1331 }
1337 1332
1333 function getSubscriptionFilters(subscription)
1334 {
1335 return new Promise((resolve, reject) =>
1336 {
1337 browser.runtime.sendMessage({
Thomas Greiner 2018/03/05 16:43:33 `browser.runtime.sendMessage()` already returns a
saroyanm 2018/03/05 16:51:13 Didn't know that we already return a promise, will
saroyanm 2018/03/05 17:18:39 Hmm, Apparently the polyfill doesn't return Promis
Thomas Greiner 2018/03/06 13:08:47 It's not actually a polyfill and more of a mock so
1338 type: "filters.get",
1339 subscriptionUrl: subscription.url
1340 }, resolve);
1341 });
1342 }
1343
1338 function hidePref(key, value) 1344 function hidePref(key, value)
1339 { 1345 {
1340 let element = document.querySelector("[data-pref='" + key + "']"); 1346 let element = document.querySelector("[data-pref='" + key + "']");
1341 if (element) 1347 if (element)
1342 element.setAttribute("aria-hidden", value); 1348 element.setAttribute("aria-hidden", value);
1343 } 1349 }
1344 1350
1345 function getPref(key, callback) 1351 function getPref(key, callback)
1346 { 1352 {
1347 let checkPref = getPref.checks[key] || getPref.checkNone; 1353 let checkPref = getPref.checks[key] || getPref.checkNone;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 "ui_warn_tracking"] 1471 "ui_warn_tracking"]
1466 }); 1472 });
1467 browser.runtime.sendMessage({ 1473 browser.runtime.sendMessage({
1468 type: "subscriptions.listen", 1474 type: "subscriptions.listen",
1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1475 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1470 "title", "downloadStatus", "downloading"] 1476 "title", "downloadStatus", "downloading"]
1471 }); 1477 });
1472 1478
1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1479 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1474 window.addEventListener("hashchange", onHashChange, false); 1480 window.addEventListener("hashchange", onHashChange, false);
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