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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: js/desktop-options.js
===================================================================
--- a/js/desktop-options.js
+++ b/js/desktop-options.js
@@ -468,7 +468,6 @@
updateFilter(filter);
setCustomFiltersView("read");
- isCustomFiltersLoaded = true;
}
function removeCustomFilter(text)
@@ -1147,18 +1146,14 @@
},
(subscriptions) =>
{
- // Load filters
- for (let subscription of subscriptions)
+ let customFilterPromises = subscriptions.map((subscription) =>
+ 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.
+
+ Promise.all(customFilterPromises).then((filters) =>
{
- browser.runtime.sendMessage({
- type: "filters.get",
- subscriptionUrl: subscription.url
- },
- (filters) =>
- {
- loadCustomFilters(filters);
- });
- }
+ 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
+ isCustomFiltersLoaded = true;
+ });
});
loadRecommendations();
browser.runtime.sendMessage({
@@ -1335,6 +1330,17 @@
}
}
+function getSubscriptionFilters(subscription)
+{
+ return new Promise((resolve, reject) =>
+ {
+ 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
+ type: "filters.get",
+ subscriptionUrl: subscription.url
+ }, resolve);
+ });
+}
+
function hidePref(key, value)
{
let element = document.querySelector("[data-pref='" + key + "']");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld