fix _downloadJsonData undefined error
This commit is contained in:
parent
8e1a040a1b
commit
35078555cd
@ -31,25 +31,18 @@
|
|||||||
return "en-US";
|
return "en-US";
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -283,13 +259,6 @@ var DirectoryLinksProvider = {
|
@@ -288,7 +264,6 @@ var DirectoryLinksProvider = {
|
||||||
},
|
uri = uri.replace("%CHANNEL%", UpdateUtils.UpdateChannel);
|
||||||
|
|
||||||
_fetchAndCacheLinks: function DirectoryLinksProvider_fetchAndCacheLinks(uri) {
|
return this._downloadJsonData(uri).then(json => {
|
||||||
- // Replace with the same display locale used for selecting links data
|
|
||||||
- uri = uri.replace("%LOCALE%", this.locale);
|
|
||||||
- uri = uri.replace("%CHANNEL%", UpdateUtils.UpdateChannel);
|
|
||||||
-
|
|
||||||
- return this._downloadJsonData(uri).then(json => {
|
|
||||||
- return OS.File.writeAtomic(this._directoryFilePath, json, {tmpPath: this._directoryFilePath + ".tmp"});
|
- return OS.File.writeAtomic(this._directoryFilePath, json, {tmpPath: this._directoryFilePath + ".tmp"});
|
||||||
- });
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
@@ -299,31 +274,6 @@ var DirectoryLinksProvider = {
|
||||||
@@ -298,33 +267,6 @@ var DirectoryLinksProvider = {
|
|
||||||
* @return promise resolved to json string, "{}" returned if status != 200
|
|
||||||
*/
|
*/
|
||||||
_downloadJsonData: function DirectoryLinksProvider__downloadJsonData(uri) {
|
_downloadJsonData: function DirectoryLinksProvider__downloadJsonData(uri) {
|
||||||
- let deferred = Promise.defer();
|
let deferred = Promise.defer();
|
||||||
- let xmlHttp = this._newXHR();
|
- let xmlHttp = this._newXHR();
|
||||||
-
|
-
|
||||||
- xmlHttp.onload = function(aResponse) {
|
- xmlHttp.onload = function(aResponse) {
|
||||||
@ -75,19 +68,13 @@
|
|||||||
- deferred.reject("Error fetching " + uri);
|
- deferred.reject("Error fetching " + uri);
|
||||||
- Cu.reportError(e);
|
- Cu.reportError(e);
|
||||||
- }
|
- }
|
||||||
- return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
@@ -337,23 +287,6 @@ var DirectoryLinksProvider = {
|
||||||
@@ -332,30 +274,6 @@ var DirectoryLinksProvider = {
|
return this._downloadDeferred.promise;
|
||||||
* @return promise resolved immediately if no download needed, or upon completion
|
}
|
||||||
*/
|
|
||||||
_fetchAndCacheLinksIfNecessary: function DirectoryLinksProvider_fetchAndCacheLinksIfNecessary(forceDownload=false) {
|
|
||||||
- if (this._downloadDeferred) {
|
|
||||||
- // fetching links already - just return the promise
|
|
||||||
- return this._downloadDeferred.promise;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (forceDownload || this._needsDownload) {
|
- if (forceDownload || this._needsDownload) {
|
||||||
- this._downloadDeferred = Promise.defer();
|
- this._downloadDeferred = Promise.defer();
|
||||||
- this._fetchAndCacheLinks(this._linksURL).then(() => {
|
- this._fetchAndCacheLinks(this._linksURL).then(() => {
|
||||||
@ -105,8 +92,17 @@
|
|||||||
- return this._downloadDeferred.promise;
|
- return this._downloadDeferred.promise;
|
||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
- // download is not needed
|
// download is not needed
|
||||||
- return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
@@ -362,10 +295,6 @@ var DirectoryLinksProvider = {
|
||||||
|
* @return true if download is needed, false otherwise
|
||||||
|
*/
|
||||||
|
get _needsDownload () {
|
||||||
|
- // fail if last download occured less then 24 hours ago
|
||||||
|
- if ((Date.now() - this._lastDownloadMS) > this._downloadIntervalMS) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
|
Loading…
Reference in New Issue
Block a user