Fix testing factory filters on non factories
This commit is contained in:
parent
aa35602827
commit
56477d4e96
|
@ -631,10 +631,14 @@ export const _cacheFind = traceFunction("cacheFind", function _cacheFind(filter:
|
||||||
const mod = cache[key];
|
const mod = cache[key];
|
||||||
if (!mod?.loaded || mod?.exports == null) continue;
|
if (!mod?.loaded || mod?.exports == null) continue;
|
||||||
|
|
||||||
if (filter.$$vencordIsFactoryFilter && filter(wreq.m[key])) {
|
if (filter.$$vencordIsFactoryFilter) {
|
||||||
|
if (filter(wreq.m[key])) {
|
||||||
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] };
|
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (filter(mod.exports)) {
|
if (filter(mod.exports)) {
|
||||||
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] };
|
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] };
|
||||||
}
|
}
|
||||||
|
@ -686,10 +690,14 @@ export function cacheFindAll(filter: FilterFn) {
|
||||||
const mod = cache[key];
|
const mod = cache[key];
|
||||||
if (!mod?.loaded || mod?.exports == null) continue;
|
if (!mod?.loaded || mod?.exports == null) continue;
|
||||||
|
|
||||||
if (filter.$$vencordIsFactoryFilter && filter(wreq.m[key])) {
|
if (filter.$$vencordIsFactoryFilter) {
|
||||||
|
if (filter(wreq.m[key])) {
|
||||||
ret.push(mod.exports);
|
ret.push(mod.exports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (filter(mod.exports)) {
|
if (filter(mod.exports)) {
|
||||||
ret.push(mod.exports);
|
ret.push(mod.exports);
|
||||||
}
|
}
|
||||||
|
@ -754,11 +762,14 @@ export const cacheFindBulk = traceFunction("cacheFindBulk", function cacheFindBu
|
||||||
const filter = filters[i];
|
const filter = filters[i];
|
||||||
if (filter == null) continue;
|
if (filter == null) continue;
|
||||||
|
|
||||||
if (filter.$$vencordIsFactoryFilter && filter(wreq.m[key])) {
|
if (filter.$$vencordIsFactoryFilter) {
|
||||||
|
if (filter(wreq.m[key])) {
|
||||||
results[i] = mod.exports;
|
results[i] = mod.exports;
|
||||||
filters[i] = undefined;
|
filters[i] = undefined;
|
||||||
|
|
||||||
if (++found === length) break outer;
|
if (++found === length) break outer;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,9 +202,12 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
|
||||||
|
|
||||||
for (const [filter, callback] of waitForSubscriptions) {
|
for (const [filter, callback] of waitForSubscriptions) {
|
||||||
try {
|
try {
|
||||||
if (filter.$$vencordIsFactoryFilter && filter(originalMod)) {
|
if (filter.$$vencordIsFactoryFilter) {
|
||||||
|
if (filter(originalMod)) {
|
||||||
waitForSubscriptions.delete(filter);
|
waitForSubscriptions.delete(filter);
|
||||||
callback(exports, { id, exportKey: null, factory: originalMod });
|
callback(exports, { id, exportKey: null, factory: originalMod });
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue