| Index: js/desktop-options.js |
| =================================================================== |
| --- a/js/desktop-options.js |
| +++ b/js/desktop-options.js |
| @@ -26,6 +26,7 @@ |
| let acceptableAdsUrl = null; |
| let acceptableAdsPrivacyUrl = null; |
| let isCustomFiltersLoaded = false; |
| +let additionalSubscriptions = []; |
| let {getMessage} = browser.i18n; |
| let {setElementText} = ext.i18n; |
| let customFilters = []; |
| @@ -237,7 +238,17 @@ |
| { |
| control.setAttribute("aria-checked", item.disabled == false); |
| if (isAcceptableAds(item.url) && this == collections.filterLists) |
| + { |
| control.disabled = true; |
| + } |
| + } |
| + if (additionalSubscriptions.includes(item.url)) |
| + { |
| + element.classList.add("preconfigured"); |
| + let disablePreconfigures = |
| + element.querySelectorAll("[data-disable~='preconfigured']"); |
| + for (let disablePreconfigure of disablePreconfigures) |
| + disablePreconfigure.disabled = true; |
| } |
| let lastUpdateElement = element.querySelector(".last-update"); |
| @@ -939,7 +950,7 @@ |
| }); |
| for (let key of customize) |
| { |
| - getPref(key, (value) => |
| + getHidePref(key, (value) => |
| { |
| onPrefMessage(key, value, true); |
| }); |
| @@ -1119,7 +1130,7 @@ |
| let acceptableAdsForm = E("acceptable-ads"); |
| if (hasPrivacyConflict()) |
| { |
| - getPref("ui_warn_tracking", (showTrackingWarning) => |
| + getHidePref("ui_warn_tracking", (showTrackingWarning) => |
| { |
| acceptableAdsForm.classList.toggle("show-warning", showTrackingWarning); |
| }); |
| @@ -1154,35 +1165,24 @@ |
| }); |
| }); |
| loadRecommendations(); |
| - browser.runtime.sendMessage({ |
| - type: "prefs.get", |
| - key: "subscriptions_exceptionsurl" |
| - }, |
| - (url) => |
| + let preloadPrefs = ["subscriptions_exceptionsurl", |
| + "subscriptions_exceptionsurl_privacy", |
| + "additional_subscriptions"]; |
| + getPrefs(preloadPrefs).then(prefs => |
| { |
| - acceptableAdsUrl = url; |
| + [acceptableAdsUrl, acceptableAdsPrivacyUrl, |
| + additionalSubscriptions] = prefs; |
| - browser.runtime.sendMessage({ |
| - type: "prefs.get", |
| - key: "subscriptions_exceptionsurl_privacy" |
| - }, |
| - (urlPrivacy) => |
| - { |
| - acceptableAdsPrivacyUrl = urlPrivacy; |
| + return browser.runtime.sendMessage({ |
| + type: "subscriptions.get", |
| + downloadable: true |
| + }); |
| + }).then((subscriptions) => |
| + { |
| + for (let subscription of subscriptions) |
| + onSubscriptionMessage("added", subscription); |
| - // Load user subscriptions |
| - browser.runtime.sendMessage({ |
| - type: "subscriptions.get", |
| - downloadable: true |
| - }, |
| - (subscriptions) => |
| - { |
| - for (let subscription of subscriptions) |
| - onSubscriptionMessage("added", subscription); |
| - |
| - setAcceptableAds(); |
| - }); |
| - }); |
| + setAcceptableAds(); |
| }); |
| } |
| @@ -1342,9 +1342,17 @@ |
| element.setAttribute("aria-hidden", value); |
| } |
| -function getPref(key, callback) |
| +function getPrefs(prefKeys) |
| { |
| - let checkPref = getPref.checks[key] || getPref.checkNone; |
| + prefKeys = prefKeys.map(key => browser.runtime.sendMessage({ |
| + type: "prefs.get", key |
| + })); |
| + return Promise.all(prefKeys); |
| +} |
| + |
| +function getHidePref(key, callback) |
| +{ |
| + let checkPref = getHidePref.checks[key] || getHidePref.checkNone; |
| checkPref((isActive) => |
| { |
| if (!isActive) |
| @@ -1360,16 +1368,16 @@ |
| }); |
| } |
| -getPref.checkNone = function(callback) |
| +getHidePref.checkNone = function(callback) |
| { |
| callback(true); |
| }; |
| -getPref.checks = |
| +getHidePref.checks = |
| { |
| notifications_ignoredcategories(callback) |
| { |
| - getPref("notifications_showui", callback); |
| + getHidePref("notifications_showui", callback); |
| } |
| }; |