From 2ae503d9305ad7bb211ae7b79dc988552f5842be Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Tue, 3 Mar 2026 20:38:40 -0500 Subject: [PATCH] BetterSettings: Fix For New Menu --- src/plugins/_core/settings.tsx | 8 --- src/plugins/betterSettings/index.tsx | 91 ++++++++-------------------- 2 files changed, 24 insertions(+), 75 deletions(-) diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index d5a57d933..eb87cb137 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -152,14 +152,6 @@ export default definePlugin({ } ] }, - { - find: "#{intl::USER_SETTINGS_ACTIONS_MENU_LABEL}", - replacement: { - // Skip the check Discord performs to make sure the section being selected in the user settings context menu is valid - match: /null!=\(\i=Object.values\(\i\.\i\).{0,50}?&&(?=\(0,\i\.openUserSettings\)\(\i,\{section:\i)/, - replace: "" - } - }, { find: ".buildLayout().map", replacement: { diff --git a/src/plugins/betterSettings/index.tsx b/src/plugins/betterSettings/index.tsx index 7b0b3517e..1f2578b94 100644 --- a/src/plugins/betterSettings/index.tsx +++ b/src/plugins/betterSettings/index.tsx @@ -7,14 +7,13 @@ import { definePluginSettings } from "@api/Settings"; import { disableStyle, enableStyle } from "@api/Styles"; import { buildPluginMenuEntries, buildThemeMenuEntries } from "@equicordplugins/equicordToolbox/menu"; -import SettingsPlugin from "@plugins/_core/settings"; import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findCssClassesLazy } from "@webpack"; import { ComponentDispatch, FocusLock, Menu, useEffect, useRef } from "@webpack/common"; -import type { HTMLAttributes, ReactElement } from "react"; +import type { HTMLAttributes } from "react"; import fullHeightStyle from "./fullHeightContext.css?managed"; @@ -171,13 +170,9 @@ export default definePlugin({ find: "#{intl::USER_SETTINGS_ACTIONS_MENU_LABEL}", replacement: [ { - match: /=\[\];(\i)(?=\.forEach.{0,200}?"logout"===\i.{0,100}?(\i)\.get\(\i\))/, - replace: "=$self.wrapMap([]);$self.transformSettingsEntries($1,$2)", + match: /(\i)=(.{0,20}openUserSettings\)\(\i\)\));/, + replace: "$1=$self.transformSettingsElements($2);", }, - { - match: /case \i\.\i\.DEVELOPER_OPTIONS:return \i;/, - replace: "$&case 'EquicordPlugins':return $self.buildPluginMenuEntries(true);case 'EquicordThemes':return $self.buildThemeMenuEntries();" - } ] }, ], @@ -200,72 +195,34 @@ export default definePlugin({ return ; }, - transformSettingsEntries(list: SettingsEntry[], keyMap: Map) { + transformSettingsElements(list) { const items: any[] = []; - const equicordItems: SettingsEntry[] = [ - { section: "EquicordSettings", label: "Settings" }, - { section: "EquicordPlugins", label: "Plugins" }, - { section: "EquicordThemes", label: "Themes" }, - { section: "EquicordUpdater", label: "Updater" }, - { section: "EquicordChangelog", label: "Changelog" }, - { section: "EquicordCloud", label: "Cloud" }, - { section: "EquicordBackupAndRestore", label: "Backup & Restore" }, - { section: "EquicordPatchHelper", label: "Patch Helper" }, - ]; - for (const [section, key] of SettingsPlugin.settingsSectionMap) { - const entry = SettingsPlugin.customEntries.find(e => key.endsWith(e.key)); - if (entry) equicordItems.push({ section, label: entry.title }); - } + for (const item of list) { + const { key, props } = item; + if (!props) continue; - if (settings.store.organizeMenu) { - for (const item of list) { - if (!item.label || item.predicate != null && !item.predicate()) continue; + if (key === "equicord_plugins" || key === "equicord_themes") { + const children = key === "equicord_plugins" + ? buildPluginMenuEntries() + : buildThemeMenuEntries(); - if (item.section === "HEADER") { - keyMap.set(item.label, item.label); - items.push({ section: item.label, items: [] }); - } else if (item.section !== "DIVIDER" && keyMap.has(item.section)) { - items.at(-1)?.items.push(item); - } + items.push( + + {children} + + ); + } else if (key.endsWith("_section") && props.label) { + items.push( + + {this.transformSettingsElements(props.children)} + + ); + } else { + items.push(item); } - - keyMap.set("Equicord", "Equicord"); - items.push({ - section: "Equicord", - items: equicordItems - }); - } else { - items.push(...list, ...equicordItems); } return items; - }, - - wrapMap(toWrap: TransformedSettingsEntry[]) { - if (!settings.store.organizeMenu) return toWrap; - // @ts-expect-error - toWrap.map = function (render: (item: SettingsEntry) => ReactElement) { - return this - .filter(a => a.items.length > 0) - .map(({ section, items }) => { - const children = items.map(render); - if (section) { - return ( - - {children} - - ); - } else { - return children; - } - }); - }; - - return toWrap; } });