Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -224,37 +224,36 @@ |
if (!addSubscription && !addAcceptable) |
return; |
- function notifyUser() |
+ Promise.resolve(addSubscription && fetch("subscriptions.xml") |
+ .then(function(response) |
+ { |
+ return response.text(); |
+ }) |
+ .then(function(text) |
+ { |
+ var doc = new DOMParser().parseFromString(text, "application/xml"); |
+ var nodes = doc.getElementsByTagName("subscription"); |
+ var node = Utils.chooseFilterSubscription(nodes); |
+ var subscription = node && Subscription.fromURL(node.getAttribute("url")); |
+ |
+ if (subscription) |
+ { |
+ FilterStorage.addSubscription(subscription); |
+ |
+ subscription.disabled = false; |
+ subscription.title = node.getAttribute("title"); |
+ subscription.homepage = node.getAttribute("homepage"); |
+ |
+ if (subscription instanceof DownloadableSubscription && |
+ !subscription.lastDownload) |
+ Synchronizer.execute(subscription); |
+ } |
+ }) |
+ ).then(function() |
{ |
if (!Prefs.suppress_first_run_page) |
ext.pages.open(ext.getURL("firstRun.html")); |
- } |
- |
- if (addSubscription) |
- { |
- // Load subscriptions data |
- var request = new XMLHttpRequest(); |
- request.open("GET", "subscriptions.xml"); |
- request.addEventListener("load", function() |
- { |
- var node = Utils.chooseFilterSubscription(request.responseXML.getElementsByTagName("subscription")); |
- var subscription = (node ? Subscription.fromURL(node.getAttribute("url")) : null); |
- if (subscription) |
- { |
- FilterStorage.addSubscription(subscription); |
- subscription.disabled = false; |
- subscription.title = node.getAttribute("title"); |
- subscription.homepage = node.getAttribute("homepage"); |
- if (subscription instanceof DownloadableSubscription && !subscription.lastDownload) |
- Synchronizer.execute(subscription); |
- |
- notifyUser(); |
- } |
- }, false); |
- request.send(null); |
- } |
- else |
- notifyUser(); |
+ }); |
} |
Prefs.onChanged.addListener(function(name) |