[Settings] Move to proper one-time patch

This commit is contained in:
Beef 2022-10-27 18:14:01 +01:00
parent 88e4f357a4
commit e32d331c5e

View file

@ -2,30 +2,29 @@ import { React, i18n } from "@metro/common";
import { findByDisplayName } from "@metro/filters"; import { findByDisplayName } from "@metro/filters";
import { after } from "@lib/patcher"; import { after } from "@lib/patcher";
import findInReactTree from "@utils/findInReactTree"; import findInReactTree from "@utils/findInReactTree";
import SettingsSection from "./components/SettingsSection"; import SettingsSection from "@ui/settings/components/SettingsSection";
import General from "./components/General"; import General from "@ui/settings/pages/General";
import AssetBrowser from "./components/AssetBrowser"; import AssetBrowser from "@ui/settings/pages/AssetBrowser";
const screensModule = findByDisplayName("getScreens", false); const screensModule = findByDisplayName("getScreens", false);
const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false); const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false);
export default function initSettings() { export default function initSettings() {
const screensPatch = after("default", screensModule, (args, ret) => { after("default", screensModule, (args, ret) => {
return { return {
...ret, ...ret,
VendettaSettings: { VendettaSettings: {
title: "Vendetta", title: "Vendetta",
render: General render: General,
}, },
VendettaAssetBrowser: { VendettaAssetBrowser: {
title: "Asset Browser", title: "Asset Browser",
render: AssetBrowser render: AssetBrowser,
} },
} }
}); });
const settingsPatch = after("default", settingsModule, (args, _ret) => { after("default", settingsModule, (args, _ret) => {
settingsPatch();
const toPatch = findInReactTree(_ret.props.children, i => i.type && i.type.name === "UserSettingsOverview"); const toPatch = findInReactTree(_ret.props.children, i => i.type && i.type.name === "UserSettingsOverview");
// Upload logs button gone // Upload logs button gone
@ -39,5 +38,5 @@ export default function initSettings() {
const index = children.findIndex((c: any) => titles.includes(c.props.title)); const index = children.findIndex((c: any) => titles.includes(c.props.title));
children.splice(index === -1 ? 4 : index, 0, <SettingsSection navigation={toPatch.props.navigation} />); children.splice(index === -1 ? 4 : index, 0, <SettingsSection navigation={toPatch.props.navigation} />);
}); });
}); }, true);
} }