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 + "']"); |