Add more checks for check function

This commit is contained in:
DianaXWiki 2024-10-31 18:59:33 +02:00
parent e22d3c812c
commit 16c0b7374d

View File

@ -11,11 +11,22 @@ define([
let e = ext[id];
if (!Array.isArray(e)) { e = []; }
return e.map(_ext => {
return new Promise((resolve, reject) => {
if (typeof(ext.check) !== "function") { return void resolve(_ext); }
ext.check().then(() => {
return new Promise((resolve) => {
if (typeof _ext.check === "function") {
const checkResult = _ext.check();
if (checkResult && typeof checkResult.then === "function") {
checkResult.then(() => {
resolve(_ext);
}).catch(() => {
console.error("Check failed for extension:", _ext);
resolve(null);
});
} else {
resolve(_ext);
}
} else {
resolve(_ext);
}).catch(reject);
}
});
});
};