From b4f98e5066aa41f986865f4b598593afc9161d3b Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 22 Jan 2023 04:26:33 +0100 Subject: [PATCH] Fix Settings ContextMenu Shortcuts & Settings on canary --- src/plugins/settings.tsx | 75 ++++++++++++++++++++++++++++++++-------- src/webpack/common.tsx | 5 ++- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/plugins/settings.tsx b/src/plugins/settings.tsx index 183798af..36bf5257 100644 --- a/src/plugins/settings.tsx +++ b/src/plugins/settings.tsx @@ -17,10 +17,12 @@ */ import { Settings } from "@api/settings"; +import PatchHelper from "@components/PatchHelper"; import { Devs } from "@utils/constants"; import Logger from "@utils/Logger"; import { LazyComponent } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; +import { Router } from "@webpack/common"; import gitHash from "~git-hash"; @@ -62,23 +64,68 @@ export default definePlugin({ } } }, - replace: (m, mod) => { - const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Plugins.plugins.Settings.tabs.updater},' : ""; - const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"Patch Helper",element:Vencord.Components.PatchHelper},' : ""; - return ( - `{section:${mod}.ID.HEADER,label:"Vencord"},` + - '{section:"VencordSettings",label:"Vencord",element:Vencord.Plugins.plugins.Settings.tabs.vencord},' + - '{section:"VencordPlugins",label:"Plugins",element:Vencord.Plugins.plugins.Settings.tabs.plugins},' + - '{section:"VencordThemes",label:"Themes",element:Vencord.Plugins.plugins.Settings.tabs.themes},' + - updater + - '{section:"VencordSettingsSync",label:"Backup & Restore",element:Vencord.Plugins.plugins.Settings.tabs.sync},' + - patchHelper + - `{section:${mod}.ID.DIVIDER},${m}` - ); - } + replace: "...$self.makeSettingsCategories($1),$&" } }], + makeSettingsCategories({ ID }: { ID: Record; }) { + const makeOnClick = (tab: string) => () => Router.open(tab); + + const cats = [ + { + section: ID.HEADER, + label: "Vencord" + }, { + section: "VencordSettings", + label: "Vencord", + element: () => , + onClick: makeOnClick("VencordSettings") + }, { + section: "VencordPlugins", + label: "Plugins", + element: () => , + onClick: makeOnClick("VencordPlugins") + }, { + section: "VencordThemes", + label: "Themes", + element: () => , + onClick: makeOnClick("VencordThemes") + } + ] as Array<{ + section: unknown, + label?: string; + element?: React.ComponentType; + onClick?(): void; + }>; + + if (!IS_WEB) + cats.push({ + section: "VencordUpdater", + label: "Updater", + element: () => , + onClick: makeOnClick("VencordUpdater") + }); + + cats.push({ + section: "VencordSettingsSync", + label: "Backup & Restore", + element: () => , + onClick: makeOnClick("VencordSettingsSync") + }); + + if (IS_DEV) + cats.push({ + section: "VencordPatchHelper", + label: "Patch Helper", + element: PatchHelper!, + onClick: makeOnClick("VencordPatchHelper") + }); + + cats.push({ section: ID.DIVIDER }); + + return cats; + }, + options: { settingsLocation: { type: OptionType.SELECT, diff --git a/src/webpack/common.tsx b/src/webpack/common.tsx index 855b887b..0be47ff7 100644 --- a/src/webpack/common.tsx +++ b/src/webpack/common.tsx @@ -182,7 +182,9 @@ waitFor(["getMember", "initialize"], m => GuildMemberStore = m); waitFor("getRelationshipType", m => RelationshipStore = m); waitFor(["Hovers", "Looks", "Sizes"], m => Button = m); -waitFor(filters.byCode("helpdeskArticleId"), m => Switch = m); + +waitFor(filters.byCode("tooltipNote", "ringTarget"), m => Switch = m); + waitFor(["Positions", "Colors"], m => Tooltip = m); waitFor(m => m.Types?.PRIMARY === "cardPrimary", m => Card = m); @@ -305,3 +307,4 @@ export const ContextMenu = mapMangledModuleLazy('type:"CONTEXT_MENU_OPEN"', { export const MaskedLinkStore = mapMangledModuleLazy('"MaskedLinkStore"', { openUntrustedLink: filters.byCode(".apply(this,arguments)") }); +