From eeda090fbab7d6c97c9c637574f29e621b752d3a Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Fri, 14 Nov 2025 19:43:36 +0100 Subject: [PATCH] Bump to 1.1.10-4 and fix tabs on newer version --- scripts/build.mjs | 2 +- src/lib/ui/settings/patches/tabs.tsx | 77 +++++++++++++++++++--------- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index c6d1c4d..07946b4 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -77,7 +77,7 @@ const config = { constModules: { globals: { "bunny-build-info": { - version: `"1.1.10-3"`, + version: `"1.1.10-4"`, }, }, }, diff --git a/src/lib/ui/settings/patches/tabs.tsx b/src/lib/ui/settings/patches/tabs.tsx index cde706c..0f15ca1 100644 --- a/src/lib/ui/settings/patches/tabs.tsx +++ b/src/lib/ui/settings/patches/tabs.tsx @@ -1,14 +1,13 @@ import { after } from "@lib/api/patcher"; -import { findInReactTree } from "@lib/utils"; import { TableRow } from "@metro/common/components"; import { findByNameLazy, findByPropsLazy } from "@metro/wrappers"; import { registeredSections } from "@ui/settings"; import { CustomPageRenderer, wrapOnPress } from "./shared"; -import { Strings } from "@core/i18n"; -import { TableRowIcon } from "@metro/common/components"; +import { findInReactTree } from "@lib/utils"; const settingConstants = findByPropsLazy("SETTING_RENDERER_CONFIG"); +const createListModule = findByPropsLazy("createList"); const SettingsOverviewScreen = findByNameLazy("SettingsOverviewScreen", false); function useIsFirstRender() { @@ -83,27 +82,59 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) { }); }); - unpatches.push( - after("default", SettingsOverviewScreen, (_, ret) => { - if (useIsFirstRender()) return; // :shrug: + try { + unpatches.push( + after("createList", createListModule, function (args, ret) { + const [config] = args; - 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; + if (config?.sections && Array.isArray(config.sections)) { + const sections = config.sections; - Object.keys(registeredSections).forEach((sect) => { - // Prevent duplicate insertion: on some resumes/re-renders the same - // 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 (exists) return; - sections.splice(index++, 0, { - label: sect, - title: sect, - settings: registeredSections[sect].map((a) => a.key), + const accountSectionIndex = sections.findIndex((i: any) => + i.settings?.includes("ACCOUNT"), + ); + + if (accountSectionIndex !== -1) { + // Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816 + + let index = accountSectionIndex + 1; + + 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), + }); }); - }); - }), - ); + }), + ); + } }