Skip to content

Commit 6550e03

Browse files
committed
fix(lib/discord/design): update FormSwitch filter for 321203+
1 parent 13ffdbc commit 6550e03

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

lib/discord/src/design.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { lookupModule } from '@revenge-mod/modules/finders'
1+
import { lookupModule, lookupModules } from '@revenge-mod/modules/finders'
22
import {
33
withDependencies,
44
withProps,
5-
withSingleProp,
65
} from '@revenge-mod/modules/finders/filters'
6+
import { getModuleDependencies } from '@revenge-mod/modules/metro/utils'
77
import {
88
ReactJSXRuntimeModuleId,
99
ReactModuleId,
@@ -13,7 +13,7 @@ import { proxify } from '@revenge-mod/utils/proxy'
1313
import { ImportTrackerModuleId } from './common'
1414
import type { DiscordModules } from './types'
1515

16-
const { loose, relative } = withDependencies
16+
const { loose } = withDependencies
1717

1818
// design/native.tsx
1919
export let Design: Design = proxify(
@@ -48,31 +48,36 @@ export let Design: Design = proxify(
4848

4949
// design/components/Forms/native/FormSwitch.native.tsx
5050
export let FormSwitch: DiscordModules.Components.FormSwitch = proxify(() => {
51-
const [module] = lookupModule(
52-
withSingleProp<{
53-
FormSwitch: DiscordModules.Components.FormSwitch
54-
}>('FormSwitch').and(
55-
withDependencies([
51+
// TODO: Possibly come up with a better dependency fingerprinting API
52+
// to not have to deal with this bullshit
53+
54+
for (const [, id] of lookupModules(
55+
withDependencies(
56+
loose([
5657
null,
5758
ReactModuleId,
5859
ReactNativeModuleId,
5960
ReactJSXRuntimeModuleId,
60-
null,
61-
null,
62-
null,
63-
null,
64-
null,
65-
null,
66-
null,
67-
// Checkmark and X icons
68-
relative(1),
69-
relative(2),
70-
ImportTrackerModuleId,
7161
]),
72-
),
73-
)
62+
).keyAs('revenge.discord.design.FormSwitch'),
63+
{
64+
initialize: false,
65+
},
66+
)) {
67+
const deps = getModuleDependencies(id)!
68+
console.log(id, deps.at(-4), deps.at(-5))
69+
if (deps.at(-1) !== ImportTrackerModuleId) continue
7470

75-
if (module) return (FormSwitch = module.FormSwitch)
71+
if (
72+
// TODO: Remove once stable > 321203
73+
(deps.at(-2) === id + 2 && deps.at(-3) === id + 1) ||
74+
// 321203+
75+
(deps.at(-4) === id + 2 && deps.at(-5) === id + 1)
76+
) {
77+
const FormSwitch_ = __r(id)!.FormSwitch
78+
if (FormSwitch_) return (FormSwitch = FormSwitch_)
79+
}
80+
}
7681
})!
7782

7883
export interface Design {

0 commit comments

Comments
 (0)