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]; 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) {
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] as AnyModuleFactory }; if (filter(wreq.m[key])) {
return { result: mod.exports, id: key, exportKey: null, factory: wreq.m[key] as AnyModuleFactory };
}
continue;
} }
if (filter(mod.exports)) { if (filter(mod.exports)) {
@ -692,8 +696,12 @@ 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) {
ret.push(mod.exports); if (filter(wreq.m[key])) {
ret.push(mod.exports);
}
continue;
} }
if (filter(mod.exports)) { if (filter(mod.exports)) {
@ -760,11 +768,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) {
results[i] = mod.exports; if (filter(wreq.m[key])) {
filters[i] = undefined; results[i] = mod.exports;
filters[i] = undefined;
if (++found === length) break outer;
}
if (++found === length) break outer;
break; break;
} }

View file

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