Merge branch 'immediate-finds' into immediate-finds-modules-proxy

This commit is contained in:
Nuckyz 2024-07-11 17:36:22 -03:00
commit 6213fca9ed
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
2 changed files with 25 additions and 11 deletions

View file

@ -637,8 +637,12 @@ 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])) {
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] as AnyModuleFactory };
if (filter.$$vencordIsFactoryFilter) {
if (filter(wreq.m[key])) {
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] as AnyModuleFactory };
}
continue;
}
if (filter(mod.exports)) {
@ -692,8 +696,12 @@ export function cacheFindAll(filter: FilterFn) {
const mod = cache[key];
if (!mod?.loaded || mod?.exports == null) continue;
if (filter.$$vencordIsFactoryFilter && filter(wreq.m[key])) {
ret.push(mod.exports);
if (filter.$$vencordIsFactoryFilter) {
if (filter(wreq.m[key])) {
ret.push(mod.exports);
}
continue;
}
if (filter(mod.exports)) {
@ -760,11 +768,14 @@ export const cacheFindBulk = traceFunction("cacheFindBulk", function cacheFindBu
const filter = filters[i];
if (filter == null) continue;
if (filter.$$vencordIsFactoryFilter && filter(wreq.m[key])) {
results[i] = mod.exports;
filters[i] = undefined;
if (filter.$$vencordIsFactoryFilter) {
if (filter(wreq.m[key])) {
results[i] = mod.exports;
filters[i] = undefined;
if (++found === length) break outer;
}
if (++found === length) break outer;
break;
}

View file

@ -322,9 +322,12 @@ function wrapAndPatchFactory(id: PropertyKey, originalFactory: AnyModuleFactory)
for (const [filter, callback] of waitForSubscriptions) {
try {
if (filter.$$vencordIsFactoryFilter && filter(wrappedFactory.$$vencordOriginal!)) {
waitForSubscriptions.delete(filter);
callback(exports, { id, exportKey: null, factory: wrappedFactory.$$vencordOriginal! });
if (filter.$$vencordIsFactoryFilter) {
if (filter(wrappedFactory.$$vencordOriginal!)) {
waitForSubscriptions.delete(filter);
callback(exports, { id, exportKey: null, factory: wrappedFactory.$$vencordOriginal! });
}
continue;
}