Skip to content

Commit 7098f41

Browse files
committed
fix Vencord missing from Settings right click menu & BetterSettings
1 parent 960f49b commit 7098f41

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

src/plugins/_core/settings.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ export default definePlugin({
149149
match: /(\i)\.buildLayout\(\)(?=\.map)/,
150150
replace: "$self.buildLayout($1)"
151151
}
152+
},
153+
{
154+
find: "getWebUserSettingFromSection",
155+
replacement: {
156+
match: /new Map\(\[(?=\[.{0,10}\.ACCOUNT,.{0,10}\.ACCOUNT_PANEL)/,
157+
replace: "new Map([...$self.getSettingsSectionMappings(),"
158+
}
152159
}
153160
],
154161

@@ -180,6 +187,18 @@ export default definePlugin({
180187
});
181188
},
182189

190+
getSettingsSectionMappings() {
191+
return [
192+
["VencordSettings", "vencord_main_panel"],
193+
["VencordPlugins", "vencord_plugins_panel"],
194+
["VencordThemes", "vencord_themes_panel"],
195+
["VencordUpdater", "vencord_updater_panel"],
196+
["VencordCloud", "vencord_cloud_panel"],
197+
["VencordBackupAndRestore", "vencord_backup_restore_panel"],
198+
["VencordPatchHelper", "vencord_patch_helper_panel"]
199+
];
200+
},
201+
183202
buildLayout(originalLayoutBuilder: SettingsLayoutBuilder) {
184203
const layout = originalLayoutBuilder.buildLayout();
185204
if (originalLayoutBuilder.key !== "$Root") return layout;
@@ -294,7 +313,7 @@ export default definePlugin({
294313
className: "vc-settings-header"
295314
},
296315
{
297-
section: "settings/tabs",
316+
section: "VencordSettings",
298317
label: "Vencord",
299318
element: VencordTab,
300319
className: "vc-settings"
@@ -324,7 +343,7 @@ export default definePlugin({
324343
className: "vc-cloud"
325344
},
326345
{
327-
section: "settings/tabsSync",
346+
section: "VencordBackupAndRestore",
328347
label: "Backup & Restore",
329348
element: BackupAndRestoreTab,
330349
className: "vc-backup-restore"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Discord has dumb max height logic for their context menus.
3+
* If a context menu is at the bottom of the screen, its submenus are capped to its max height and can't even grow upwards
4+
* We unset the variable they use to cap height. This allows submenus to grow as tall as they want
5+
*/
6+
7+
#user-settings-cog,
8+
[aria-activedescendant^="user-settings-cog"] {
9+
--reference-position-layer-max-height: initial !important;
10+
}

src/plugins/betterSettings/index.tsx

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
*/
66

77
import { definePluginSettings } from "@api/Settings";
8-
import { classNameFactory } from "@api/Styles";
8+
import { classNameFactory, disableStyle, enableStyle } from "@api/Styles";
99
import { buildPluginMenuEntries, buildThemeMenuEntries } from "@plugins/vencordToolbox/menu";
1010
import { Devs } from "@utils/constants";
11-
import { getIntlMessage } from "@utils/discord";
1211
import { Logger } from "@utils/Logger";
1312
import definePlugin, { OptionType } from "@utils/types";
1413
import { waitFor } from "@webpack";
1514
import { ComponentDispatch, FocusLock, Menu, useEffect, useRef } from "@webpack/common";
1615
import type { HTMLAttributes, ReactElement } from "react";
1716

17+
import fullHeightStyle from "./fullHeightContext.css?managed";
18+
1819
type SettingsEntry = { section: string, label: string; };
1920

2021
const cl = classNameFactory("");
@@ -42,6 +43,11 @@ const settings = definePluginSettings({
4243
}
4344
});
4445

46+
interface TransformedSettingsEntry {
47+
section: string;
48+
items: SettingsEntry[];
49+
}
50+
4551
interface LayerProps extends HTMLAttributes<HTMLDivElement> {
4652
mode: "SHOWN" | "HIDDEN";
4753
baseLayer?: boolean;
@@ -81,6 +87,15 @@ export default definePlugin({
8187
authors: [Devs.Kyuuhachi],
8288
settings,
8389

90+
start() {
91+
if (settings.store.organizeMenu)
92+
enableStyle(fullHeightStyle);
93+
},
94+
95+
stop() {
96+
disableStyle(fullHeightStyle);
97+
},
98+
8499
patches: [
85100
{
86101
find: "this.renderArtisanalHack()",
@@ -124,8 +139,8 @@ export default definePlugin({
124139
find: "#{intl::USER_SETTINGS_ACTIONS_MENU_LABEL}",
125140
replacement: [
126141
{
127-
match: /=\[\];if\((\i)(?=\.forEach)/,
128-
replace: "=$self.wrapMap([]);if($self.transformSettingsEntries($1)",
142+
match: /=\[\];if\((\i)(?=\.forEach.{0,100}"logout"!==\i.{0,30}(\i)\.get\(\i\))/,
143+
replace: "=$self.wrapMap([]);if($self.transformSettingsEntries($1,$2)",
129144
predicate: () => settings.store.organizeMenu
130145
},
131146
{
@@ -154,36 +169,34 @@ export default definePlugin({
154169
return <Layer {...props} />;
155170
},
156171

157-
transformSettingsEntries(list: SettingsEntry[]) {
158-
const items = [{ label: null as string | null, items: [] as SettingsEntry[] }];
172+
transformSettingsEntries(list: SettingsEntry[], keyMap: Map<string, string>) {
173+
const items = [] as TransformedSettingsEntry[];
159174

160175
for (const item of list) {
161176
if (item.section === "HEADER") {
162-
items.push({ label: item.label, items: [] });
163-
} else if (item.section === "DIVIDER") {
164-
items.push({ label: getIntlMessage("OTHER_OPTIONS"), items: [] });
165-
} else {
166-
items.at(-1)!.items.push(item);
177+
keyMap.set(item.label, item.label);
178+
items.push({ section: item.label, items: [] });
179+
} else if (item.section !== "DIVIDER" && keyMap.has(item.section)) {
180+
items.at(-1)?.items.push(item);
167181
}
168182
}
169183

170184
return items;
171185
},
172186

173-
wrapMap(toWrap: any[]) {
174-
const otherOptions = getIntlMessage("OTHER_OPTIONS");
187+
wrapMap(toWrap: TransformedSettingsEntry[]) {
175188
// @ts-expect-error
176189
toWrap.map = function (render: (item: SettingsEntry) => ReactElement<any>) {
177190
return this
178-
.filter(a => a.items.length > 0 && a.label !== otherOptions)
179-
.map(({ label, items }) => {
191+
.filter(a => a.items.length > 0)
192+
.map(({ section, items }) => {
180193
const children = items.map(render);
181-
if (label) {
194+
if (section) {
182195
return (
183196
<Menu.MenuItem
184-
key={label}
185-
id={label.replace(/\W/, "_")}
186-
label={label}
197+
key={section}
198+
id={section.replace(/\W/, "_")}
199+
label={section}
187200
>
188201
{children}
189202
</Menu.MenuItem>

0 commit comments

Comments
 (0)