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: Updated as discussed with Thomas Created March 5, 2018, 2:48 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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 for (let property in collections) 1139 for (let property in collections)
1140 collections[property].clearAll(); 1140 collections[property].clearAll();
1141 1141
1142 setCustomFiltersView("empty"); 1142 setCustomFiltersView("empty");
1143 browser.runtime.sendMessage({ 1143 browser.runtime.sendMessage({
1144 type: "subscriptions.get", 1144 type: "subscriptions.get",
1145 special: true 1145 special: true
1146 }, 1146 },
1147 (subscriptions) => 1147 (subscriptions) =>
1148 { 1148 {
1149 let customFilterPromises = subscriptions.map((subscription) => 1149 let customFilterPromises = subscriptions.map(getSubscriptionFilters);
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) => 1150 Promise.all(customFilterPromises).then((filters) =>
1153 { 1151 {
1154 loadCustomFilters([].concat(...filters)); 1152 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
1155 isCustomFiltersLoaded = true; 1153 isCustomFiltersLoaded = true;
1156 }); 1154 });
1157 }); 1155 });
1158 loadRecommendations(); 1156 loadRecommendations();
1159 browser.runtime.sendMessage({ 1157 browser.runtime.sendMessage({
1160 type: "prefs.get", 1158 type: "prefs.get",
1161 key: "subscriptions_exceptionsurl" 1159 key: "subscriptions_exceptionsurl"
1162 }, 1160 },
1163 (url) => 1161 (url) =>
1164 { 1162 {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 } 1323 }
1326 1324
1327 collections.filterLists.removeItem(subscription); 1325 collections.filterLists.removeItem(subscription);
1328 setPrivacyConflict(); 1326 setPrivacyConflict();
1329 break; 1327 break;
1330 } 1328 }
1331 } 1329 }
1332 1330
1333 function getSubscriptionFilters(subscription) 1331 function getSubscriptionFilters(subscription)
1334 { 1332 {
1335 return new Promise((resolve, reject) => 1333 return browser.runtime.sendMessage({
1336 { 1334 type: "filters.get",
1337 browser.runtime.sendMessage({ 1335 subscriptionUrl: subscription.url});
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 } 1336 }
1343 1337
1344 function hidePref(key, value) 1338 function hidePref(key, value)
1345 { 1339 {
1346 let element = document.querySelector("[data-pref='" + key + "']"); 1340 let element = document.querySelector("[data-pref='" + key + "']");
1347 if (element) 1341 if (element)
1348 element.setAttribute("aria-hidden", value); 1342 element.setAttribute("aria-hidden", value);
1349 } 1343 }
1350 1344
1351 function getPref(key, callback) 1345 function getPref(key, callback)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 "ui_warn_tracking"] 1465 "ui_warn_tracking"]
1472 }); 1466 });
1473 browser.runtime.sendMessage({ 1467 browser.runtime.sendMessage({
1474 type: "subscriptions.listen", 1468 type: "subscriptions.listen",
1475 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1476 "title", "downloadStatus", "downloading"] 1470 "title", "downloadStatus", "downloading"]
1477 }); 1471 });
1478 1472
1479 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1480 window.addEventListener("hashchange", onHashChange, false); 1474 window.addEventListener("hashchange", onHashChange, false);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld