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];
|
||||
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] };
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filter(mod.exports)) {
|
||||
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];
|
||||
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);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filter(mod.exports)) {
|
||||
ret.push(mod.exports);
|
||||
}
|
||||
|
@ -754,11 +762,14 @@ export const cacheFindBulk = traceFunction("cacheFindBulk", function cacheFindBu
|
|||
const filter = filters[i];
|
||||
if (filter == null) continue;
|
||||
|
||||
if (filter.$$vencordIsFactoryFilter && filter(wreq.m[key])) {
|
||||
if (filter.$$vencordIsFactoryFilter) {
|
||||
if (filter(wreq.m[key])) {
|
||||
results[i] = mod.exports;
|
||||
filters[i] = undefined;
|
||||
|
||||
if (++found === length) break outer;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,9 +202,12 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
|
|||
|
||||
for (const [filter, callback] of waitForSubscriptions) {
|
||||
try {
|
||||
if (filter.$$vencordIsFactoryFilter && filter(originalMod)) {
|
||||
if (filter.$$vencordIsFactoryFilter) {
|
||||
if (filter(originalMod)) {
|
||||
waitForSubscriptions.delete(filter);
|
||||
callback(exports, { id, exportKey: null, factory: originalMod });
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue