fx-compat: AddonManager.getAllAddons() now returns a promise
This commit is contained in:
parent
66a60eea64
commit
d635fdda41
2 changed files with 113 additions and 121 deletions
|
@ -373,7 +373,6 @@ Zotero.Prefs = new function(){
|
|||
async function loadExtensionDefaults() {
|
||||
var defaultBranch = Services.prefs.getDefaultBranch("");
|
||||
|
||||
return new Zotero.Promise(function (resolve) {
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
// Lines are in format `pref("[key]", [val]);`, so define a function to be called that
|
||||
|
@ -406,7 +405,7 @@ Zotero.Prefs = new function(){
|
|||
}
|
||||
}
|
||||
|
||||
AddonManager.getAllAddons(async function(addons) {
|
||||
let addons = await AddonManager.getAllAddons();
|
||||
var reusableStreamInstance = Cc['@mozilla.org/scriptableinputstream;1']
|
||||
.createInstance(Ci.nsIScriptableInputStream);
|
||||
|
||||
|
@ -481,10 +480,6 @@ Zotero.Prefs = new function(){
|
|||
Zotero.logError(e);
|
||||
}
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.getVirtualCollectionState = function (type) {
|
||||
|
|
|
@ -1309,9 +1309,10 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
|||
/**
|
||||
* @return {Promise<String[]>} - Promise for an array of extension names and versions
|
||||
*/
|
||||
this.getInstalledExtensions = Zotero.Promise.method(function () {
|
||||
var deferred = Zotero.Promise.defer();
|
||||
function onHaveInstalledAddons(installed) {
|
||||
this.getInstalledExtensions = async function () {
|
||||
var { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
|
||||
var installed = await AddonManager.getAllAddons();
|
||||
|
||||
installed.sort(function(a, b) {
|
||||
return ((a.appDisabled || a.userDisabled) ? 1 : 0) -
|
||||
((b.appDisabled || b.userDisabled) ? 1 : 0);
|
||||
|
@ -1329,13 +1330,9 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
|||
+ ((addon.appDisabled || addon.userDisabled) ? ", disabled" : "")
|
||||
+ ")");
|
||||
}
|
||||
deferred.resolve(addons);
|
||||
}
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
AddonManager.getAllAddons(onHaveInstalledAddons);
|
||||
return deferred.promise;
|
||||
});
|
||||
return addons;
|
||||
};
|
||||
|
||||
this.getString = function (name, params, num) {
|
||||
return Zotero.Intl.getString(...arguments);
|
||||
|
|
Loading…
Reference in a new issue