mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-17 02:17:03 -04:00
beef up ConsoleShortcuts
This commit is contained in:
parent
a2560ede1c
commit
6869705673
2 changed files with 39 additions and 15 deletions
|
@ -52,7 +52,18 @@ export const filters = {
|
|||
return true;
|
||||
},
|
||||
byStoreName: (name: string): FilterFn => m =>
|
||||
m.constructor?.displayName === name
|
||||
m.constructor?.displayName === name,
|
||||
|
||||
componentByCode: (...code: string[]): FilterFn => {
|
||||
const filter = filters.byCode(...code);
|
||||
return m => {
|
||||
if (filter(m)) return true;
|
||||
if (!m.$$typeof) return false;
|
||||
if (m.type) return filter(m.type); // memos
|
||||
if (m.render) return filter(m.render); // forwardRefs
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const subscriptions = new Map<FilterFn, CallbackFn>();
|
||||
|
@ -397,18 +408,9 @@ export function findStoreLazy(name: string) {
|
|||
* Finds the component which includes all the given code. Checks for plain components, memos and forwardRefs
|
||||
*/
|
||||
export function findComponentByCode(...code: string[]) {
|
||||
const filter = filters.byCode(...code);
|
||||
const res = find(m => {
|
||||
if (filter(m)) return true;
|
||||
if (!m.$$typeof) return false;
|
||||
if (m.type) return filter(m.type); // memos
|
||||
if (m.render) return filter(m.render); // forwardRefs
|
||||
return false;
|
||||
}, { isIndirect: true });
|
||||
|
||||
const res = find(filters.componentByCode(...code), { isIndirect: true });
|
||||
if (!res)
|
||||
handleModuleNotFound("findComponentByCode", ...code);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue