Bump to 1.1.10-4 and fix tabs on newer version

This commit is contained in:
kmmiio99o 2025-11-14 19:43:36 +01:00
parent b8c8f6abda
commit eeda090fba
2 changed files with 55 additions and 24 deletions

View file

@ -77,7 +77,7 @@ const config = {
constModules: { constModules: {
globals: { globals: {
"bunny-build-info": { "bunny-build-info": {
version: `"1.1.10-3"`, version: `"1.1.10-4"`,
}, },
}, },
}, },

View file

@ -1,14 +1,13 @@
import { after } from "@lib/api/patcher"; import { after } from "@lib/api/patcher";
import { findInReactTree } from "@lib/utils";
import { TableRow } from "@metro/common/components"; import { TableRow } from "@metro/common/components";
import { findByNameLazy, findByPropsLazy } from "@metro/wrappers"; import { findByNameLazy, findByPropsLazy } from "@metro/wrappers";
import { registeredSections } from "@ui/settings"; import { registeredSections } from "@ui/settings";
import { CustomPageRenderer, wrapOnPress } from "./shared"; import { CustomPageRenderer, wrapOnPress } from "./shared";
import { Strings } from "@core/i18n"; import { findInReactTree } from "@lib/utils";
import { TableRowIcon } from "@metro/common/components";
const settingConstants = findByPropsLazy("SETTING_RENDERER_CONFIG"); const settingConstants = findByPropsLazy("SETTING_RENDERER_CONFIG");
const createListModule = findByPropsLazy("createList");
const SettingsOverviewScreen = findByNameLazy("SettingsOverviewScreen", false); const SettingsOverviewScreen = findByNameLazy("SettingsOverviewScreen", false);
function useIsFirstRender() { function useIsFirstRender() {
@ -83,27 +82,59 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
}); });
}); });
unpatches.push( try {
after("default", SettingsOverviewScreen, (_, ret) => { unpatches.push(
if (useIsFirstRender()) return; // :shrug: after("createList", createListModule, function (args, ret) {
const [config] = args;
const { sections } = findInReactTree(ret, (i) => i.props?.sections).props; if (config?.sections && Array.isArray(config.sections)) {
// Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816 const sections = config.sections;
let index =
-~sections.findIndex((i: any) => i.settings.includes("ACCOUNT")) || 1;
Object.keys(registeredSections).forEach((sect) => { const accountSectionIndex = sections.findIndex((i: any) =>
// Prevent duplicate insertion: on some resumes/re-renders the same i.settings?.includes("ACCOUNT"),
// registeredSections keys may be inserted multiple times. Check if a );
// section with the same label already exists before splicing.
const exists = sections.some((s: any) => s && s.label === sect); if (accountSectionIndex !== -1) {
if (exists) return; // Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816
sections.splice(index++, 0, {
label: sect, let index = accountSectionIndex + 1;
title: sect,
settings: registeredSections[sect].map((a) => a.key), Object.keys(registeredSections).forEach((sect) => {
const alreadyExists = sections.some((s: any) => s.label === sect);
if (!alreadyExists) {
sections.splice(index++, 0, {
label: sect,
title: sect,
settings: registeredSections[sect].map((a) => a.key),
});
}
});
}
}
return ret;
}),
);
} catch {
unpatches.push(
after("default", SettingsOverviewScreen, (_, ret) => {
if (useIsFirstRender()) return; // :shrug:
const { sections } = findInReactTree(
ret,
(i) => i.props?.sections,
).props;
// Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816
let index =
-~sections.findIndex((i: any) => i.settings.includes("ACCOUNT")) || 1;
Object.keys(registeredSections).forEach((sect) => {
sections.splice(index++, 0, {
label: sect,
title: sect,
settings: registeredSections[sect].map((a) => a.key),
});
}); });
}); }),
}), );
); }
} }