diff --git a/src/entry.ts b/src/entry.ts index 6b8af88..73eabcf 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -66,6 +66,7 @@ if (typeof globalThis.__r !== "undefined") { _requireFunc = function patchedRequire(a: number) { // Initializing index.ts(x) if (a === 0) { + if (window.modules instanceof Map) window.modules = Object.fromEntries(window.modules); onceIndexRequired(v); _requireFunc = v; } else return v(a); diff --git a/src/lib/ui/settings/index.tsx b/src/lib/ui/settings/index.tsx index 37bb0fd..364a34b 100644 --- a/src/lib/ui/settings/index.tsx +++ b/src/lib/ui/settings/index.tsx @@ -2,7 +2,6 @@ import { lazy } from "react"; import type { ImageURISource } from "react-native"; -import { patchPanelUI } from "./patches/panel"; import { patchTabsUI } from "./patches/tabs"; export interface RowConfig { @@ -32,7 +31,6 @@ export function registerSection(section: { name: string; items: RowConfig[]; }) export function patchSettings() { const unpatches = new Array<() => boolean>; - patchPanelUI(unpatches); patchTabsUI(unpatches); return () => unpatches.forEach(u => u()); diff --git a/src/lib/ui/settings/patches/panel.tsx b/src/lib/ui/settings/patches/panel.tsx deleted file mode 100644 index 34671f6..0000000 --- a/src/lib/ui/settings/patches/panel.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { after } from "@lib/api/patcher"; -import { findInReactTree } from "@lib/utils"; -import { i18n, NavigationNative } from "@metro/common"; -import { LegacyFormDivider,LegacyFormIcon, LegacyFormRow, LegacyFormSection } from "@metro/common/components"; -import { findByNameLazy } from "@metro/wrappers"; -import { registeredSections } from "@ui/settings"; - -import { CustomPageRenderer, wrapOnPress } from "./shared"; -import { Strings } from "@core/i18n"; - -function SettingsSection() { - const navigation = NavigationNative.useNavigation(); - - return <> - {Object.keys(registeredSections).map(sect => registeredSections[sect].length > 0 && ( - - { /** Is usePredicate here safe? */} - {registeredSections[sect].filter(r => r.usePredicate?.() ?? true).map((row, i, arr) => ( - <> - } - trailing={} - onPress={wrapOnPress(row.onPress, navigation, row.render, row.title())} - /> - {i !== arr.length - 1 && } - - ))} - - ))} - ; -} - -export function patchPanelUI(unpatches: (() => void | boolean)[]) { - unpatches.push(after("default", findByNameLazy("getScreens", false), (_a, screens) => ({ - ...screens, - VendettaCustomPage: { - title: Strings.BUNNY, - render: () => - }, - BUNNY_CUSTOM_PAGE: { - title: Strings.BUNNY, - render: () => - } - }))); - - const unpatch = after("default", findByNameLazy("UserSettingsOverviewWrapper", false), (_a, ret) => { - const UserSettingsOverview = findInReactTree(ret.props.children, n => n.type?.name === "UserSettingsOverview"); - - unpatches.push(after("renderSupportAndAcknowledgements", UserSettingsOverview.type.prototype, (_args, { props: { children } }) => { - const index = children.findIndex((c: any) => c?.type?.name === "UploadLogsButton"); - if (index !== -1) children.splice(index, 1); - })); - - unpatches.push(after("render", UserSettingsOverview.type.prototype, (_args, res) => { - const titles = [i18n.Messages.BILLING_SETTINGS, i18n.Messages.PREMIUM_SETTINGS]; - - const sections = findInReactTree( - res.props.children, - n => n?.children?.[1]?.type === LegacyFormSection - )?.children || res.props.children; - - if (sections) { - const index = sections.findIndex((c: any) => titles.includes(c?.props.label)); - sections.splice(-~index || 4, 0, ); - } - })); - }, true); - - unpatches.push(unpatch); -} - diff --git a/src/metro/internals/modules.ts b/src/metro/internals/modules.ts index 0b4cdf4..3265512 100644 --- a/src/metro/internals/modules.ts +++ b/src/metro/internals/modules.ts @@ -6,7 +6,7 @@ import { ModuleFlags, ModulesMapInternal } from "./enums"; const { before, instead } = require("spitroast"); export const metroModules: Metro.ModuleList = window.modules; -const metroRequire: Metro.Require = window.__r; +const metroRequire = (id: string | number) => window.__r(+id); // eslint-disable-next-line func-call-spacing const moduleSubscriptions = new Map void>>();