feat: support 263+ clients
This commit is contained in:
parent
eb424aea52
commit
f1ba456474
4 changed files with 2 additions and 75 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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 && (
|
||||
<LegacyFormSection key={sect} title={sect}>
|
||||
{ /** Is usePredicate here safe? */}
|
||||
{registeredSections[sect].filter(r => r.usePredicate?.() ?? true).map((row, i, arr) => (
|
||||
<>
|
||||
<LegacyFormRow
|
||||
label={row.title()}
|
||||
leading={<LegacyFormIcon source={row.icon} />}
|
||||
trailing={<LegacyFormRow.Arrow label={row.useTrailing?.() || undefined} />}
|
||||
onPress={wrapOnPress(row.onPress, navigation, row.render, row.title())}
|
||||
/>
|
||||
{i !== arr.length - 1 && <LegacyFormDivider />}
|
||||
</>
|
||||
))}
|
||||
</LegacyFormSection>
|
||||
))}
|
||||
</>;
|
||||
}
|
||||
|
||||
export function patchPanelUI(unpatches: (() => void | boolean)[]) {
|
||||
unpatches.push(after("default", findByNameLazy("getScreens", false), (_a, screens) => ({
|
||||
...screens,
|
||||
VendettaCustomPage: {
|
||||
title: Strings.BUNNY,
|
||||
render: () => <CustomPageRenderer />
|
||||
},
|
||||
BUNNY_CUSTOM_PAGE: {
|
||||
title: Strings.BUNNY,
|
||||
render: () => <CustomPageRenderer />
|
||||
}
|
||||
})));
|
||||
|
||||
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, <SettingsSection />);
|
||||
}
|
||||
}));
|
||||
}, true);
|
||||
|
||||
unpatches.push(unpatch);
|
||||
}
|
||||
|
||||
|
|
@ -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<number, Set<() => void>>();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue