diff --git a/src/Vencord.ts b/src/Vencord.ts index 3f1576f69..8fb08db06 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -44,7 +44,7 @@ import { localStorage } from "./utils/localStorage"; import { relaunch } from "./utils/native"; import { checkForUpdates, update, UpdateLogger } from "./utils/updater"; import { onceReady } from "./webpack"; -import { SettingsRouter } from "./webpack/common"; +import { openUserSettingsPanel } from "./webpack/common"; import { patches } from "./webpack/patchWebpack"; if (IS_REPORTER) { @@ -61,7 +61,7 @@ async function syncSettings() { title: "Cloud Settings", body: "Cloud sync was disabled because this account isn't connected to the cloud App. You can enable it again by connecting this account in Cloud Settings. (note: it will store your preferences separately)", color: "var(--yellow-360)", - onClick: () => SettingsRouter.open("VencordCloud") + onClick: () => openUserSettingsPanel("equicord_cloud") }); // Disable cloud sync globally Settings.cloud.authenticated = false; @@ -80,7 +80,7 @@ async function syncSettings() { body: "We've noticed you have cloud integrations enabled in another client! Due to limitations, you will " + "need to re-authenticate to continue using them. Click here to go to the settings page to do so!", color: "var(--yellow-360)", - onClick: () => SettingsRouter.open("EquicordCloud") + onClick: () => openUserSettingsPanel("equicord_cloud") }); return; } diff --git a/src/api/SettingsSync/cloudSync.ts b/src/api/SettingsSync/cloudSync.ts index c454eea96..14c41f4a7 100644 --- a/src/api/SettingsSync/cloudSync.ts +++ b/src/api/SettingsSync/cloudSync.ts @@ -8,7 +8,7 @@ import { showNotification } from "@api/Notifications"; import { PlainSettings, Settings } from "@api/Settings"; import { Logger } from "@utils/Logger"; import { relaunch } from "@utils/native"; -import { SettingsRouter } from "@webpack/common"; +import { openUserSettingsPanel } from "@webpack/common"; import { deflateSync, inflateSync } from "fflate"; import { deauthorizeCloud, getCloudAuth, getCloudUrl } from "./cloudSetup"; @@ -79,7 +79,7 @@ export async function getCloudSettings(shouldNotify = true, force = false) { title: "Cloud Settings", body: "Cloud sync was disabled because this account isn't connected to the cloud App. You can enable it again by connecting this account in Cloud Settings. (note: it will store your preferences separately)", color: "var(--yellow-360)", - onClick: () => SettingsRouter.open("VencordCloud") + onClick: () => openUserSettingsPanel("equicord_cloud") }); // Disable cloud sync globally Settings.cloud.authenticated = false; diff --git a/src/equicordplugins/commandPalette/registry.tsx b/src/equicordplugins/commandPalette/registry.tsx index 18b73bce4..e3bf857c7 100644 --- a/src/equicordplugins/commandPalette/registry.tsx +++ b/src/equicordplugins/commandPalette/registry.tsx @@ -13,7 +13,7 @@ import { toggleEnabled } from "@equicordplugins/equicordHelper/utils"; import type { Plugin } from "@utils/types"; import { changes, checkForUpdates } from "@utils/updater"; import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { ChannelActionCreators, ChannelRouter, ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, MediaEngineStore, React, ReadStateUtils, SelectedChannelStore, SelectedGuildStore, SettingsRouter, StreamerModeStore, Toasts, useEffect, UserStore, VoiceActions } from "@webpack/common"; +import { ChannelActionCreators, ChannelRouter, ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, MediaEngineStore, openUserSettingsPanel, React, ReadStateUtils, SelectedChannelStore, SelectedGuildStore, StreamerModeStore, Toasts, useEffect, UserStore, VoiceActions } from "@webpack/common"; import type { FC, ReactElement, ReactNode } from "react"; import { Settings } from "Vencord"; @@ -1270,7 +1270,7 @@ const BUILT_IN_COMMANDS: CommandEntry[] = [ keywords: ["settings", "equicord"], categoryId: DEFAULT_CATEGORY_ID, tags: [TAG_NAVIGATION, TAG_CORE], - handler: () => SettingsRouter.open("EquicordSettings") + handler: () => openUserSettingsPanel("equicord_main") }, { id: "open-plugin-settings", @@ -1278,7 +1278,7 @@ const BUILT_IN_COMMANDS: CommandEntry[] = [ keywords: ["settings", "plugins"], categoryId: DEFAULT_CATEGORY_ID, tags: [TAG_NAVIGATION, TAG_PLUGINS], - handler: () => SettingsRouter.open("EquicordPlugins") + handler: () => openUserSettingsPanel("equicord_plugins") }, { id: "reload-windows", @@ -1292,15 +1292,15 @@ const BUILT_IN_COMMANDS: CommandEntry[] = [ ]; const DISCORD_SETTINGS_COMMANDS: Array<{ id: string; label: string; route: string; keywords: string[]; description?: string; }> = [ - { id: "settings-account", label: "Open My Account", route: "My Account", keywords: ["account", "profile"] }, - { id: "settings-privacy", label: "Open Data & Privacy", route: "Data & Privacy", keywords: ["privacy", "safety", "data"] }, - { id: "settings-notifications", label: "Open Notifications", route: "Notifications", keywords: ["notifications"] }, - { id: "settings-voice", label: "Open Voice & Video", route: "Voice & Video", keywords: ["voice", "video", "audio"] }, - { id: "settings-text", label: "Open Text & Images", route: "Text & Images", keywords: ["text", "images"] }, - { id: "settings-appearance", label: "Open Appearance", route: "Appearance", keywords: ["appearance", "theme"] }, - { id: "settings-accessibility", label: "Open Accessibility", route: "Accessibility", keywords: ["accessibility"] }, - { id: "settings-keybinds", label: "Open Keybinds", route: "Keybinds", keywords: ["keybinds", "shortcuts"] }, - { id: "settings-advanced", label: "Open Advanced", route: "Advanced", keywords: ["advanced"] } + { id: "settings-account", label: "Open My Account", route: "my_account", keywords: ["account", "profile"] }, + { id: "settings-privacy", label: "Open Data & Privacy", route: "data_and_privacy", keywords: ["privacy", "safety", "data"] }, + { id: "settings-notifications", label: "Open Notifications", route: "legacy_notifications_settings", keywords: ["notifications"] }, + { id: "settings-voice", label: "Open Voice & Video", route: "voice_and_video", keywords: ["voice", "video", "audio"] }, + { id: "settings-text", label: "Open Text & Images", route: "text_and_images", keywords: ["text", "images"] }, + { id: "settings-appearance", label: "Open Appearance", route: "appearance", keywords: ["appearance", "theme"] }, + { id: "settings-accessibility", label: "Open Accessibility", route: "accessibility", keywords: ["accessibility"] }, + { id: "settings-keybinds", label: "Open Keybinds", route: "keybinds", keywords: ["keybinds", "shortcuts"] }, + { id: "settings-advanced", label: "Open Advanced", route: "advanced", keywords: ["advanced"] } ]; const settingsCommandsById = new Map(); @@ -1686,7 +1686,7 @@ function registerUpdateCommands() { keywords: ["updates", "changelog"], categoryId: "updates", tags: [TAG_DEVELOPER, TAG_NAVIGATION], - handler: () => SettingsRouter.open("EquicordChangelog") + handler: () => openUserSettingsPanel("equicord_changelog") }); } @@ -1705,33 +1705,17 @@ function registerDiscordSettingsCommands() { categoryId: "discord-settings", tags: [TAG_NAVIGATION], handler: async () => { - const fallbackRoute = command.id === "settings-privacy" ? "Privacy & Safety" : null; - - const attemptOpen = (route: string) => { - const result = SettingsRouter.open(route); - if (result && typeof (result as Promise).then === "function") { - return (result as Promise).then(() => undefined); - } - return Promise.resolve(); - }; + const fallbackRoute = command.id === "settings-privacy" ? "privacy_and_safety" : null; try { - await new Promise((resolve, reject) => { - requestAnimationFrame(() => { - attemptOpen(command.route) - .catch(error => { - if (fallbackRoute) { - return attemptOpen(fallbackRoute); - } - throw error; - }) - .then(() => resolve()) - .catch(reject); - }); - }); + await openUserSettingsPanel(command.route); } catch (error) { - console.error("CommandPalette", "Failed to open Discord settings", command.route, error); - showToast(`Unable to open ${command.label}.`, Toasts.Type.FAILURE); + if (fallbackRoute) { + await openUserSettingsPanel(fallbackRoute); + } else { + console.error("CommandPalette", "Failed to open Discord settings", command.route, error); + showToast(`Unable to open ${command.label}.`, Toasts.Type.FAILURE); + } } } }); @@ -2022,7 +2006,7 @@ async function executeCustomCommand(command: CustomCommandDefinition) { await runCommandById(action.commandId, new Set([command.id])); break; case "settings": - SettingsRouter.open(action.route); + openUserSettingsPanel(action.route); break; case "url": { const external = (window as any)?.DiscordNative?.app?.openExternalURL; @@ -2687,7 +2671,7 @@ function registerCustomizationCommands() { keywords: ["theme", "library"], categoryId: DEFAULT_CATEGORY_ID, tags: [TAG_CUSTOMIZATION, TAG_NAVIGATION], - handler: () => SettingsRouter.open("EquicordThemes") + handler: () => openUserSettingsPanel("equicord_themes") }); } diff --git a/src/equicordplugins/iconViewer/index.tsx b/src/equicordplugins/iconViewer/index.tsx index 30d295d4c..3651d21dc 100644 --- a/src/equicordplugins/iconViewer/index.tsx +++ b/src/equicordplugins/iconViewer/index.tsx @@ -8,7 +8,7 @@ import { MagnifyingGlassIcon } from "@components/Icons"; import SettingsPlugin from "@plugins/_core/settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { StartAt } from "@utils/types"; -import { SettingsRouter } from "@webpack/common"; +import { openUserSettingsPanel } from "@webpack/common"; import IconsTab from "./IconsTab"; import { SettingsAbout } from "./subComponents"; @@ -22,7 +22,7 @@ export default definePlugin({ startAt: StartAt.WebpackReady, toolboxActions: { "Open Icons Tab"() { - SettingsRouter.open("VencordDiscordIcons"); + openUserSettingsPanel("icon_viewer"); }, }, settingsAboutComponent: SettingsAbout, diff --git a/src/equicordplugins/keyboardNavigation/commands.tsx b/src/equicordplugins/keyboardNavigation/commands.tsx index 72e065042..6cf9bffe9 100644 --- a/src/equicordplugins/keyboardNavigation/commands.tsx +++ b/src/equicordplugins/keyboardNavigation/commands.tsx @@ -10,7 +10,7 @@ import { gitHashShort } from "@shared/vencordUserAgent"; import { copyToClipboard } from "@utils/clipboard"; import { relaunch, showItemInFolder } from "@utils/native"; import { checkForUpdates, getRepo } from "@utils/updater"; -import { GuildStore, NavigationRouter, SettingsRouter, Toasts } from "@webpack/common"; +import { GuildStore, NavigationRouter, openUserSettingsPanel, Toasts } from "@webpack/common"; import gitRemote from "~git-remote"; import Plugins from "~plugins"; @@ -26,12 +26,12 @@ export interface ButtonAction { } export const actions: ButtonAction[] = [ - { id: "openEquicordSettings", label: "Open Equicord tab", callback: async () => await SettingsRouter.open("EquicordSettings"), registrar: "Equicord" }, - { id: "openPluginSettings", label: "Open Plugin tab", callback: () => SettingsRouter.open("EquicordPlugins"), registrar: "Equicord" }, - { id: "openThemesSettings", label: "Open Themes tab", callback: () => SettingsRouter.open("EquicordThemes"), registrar: "Equicord" }, - { id: "openUpdaterSettings", label: "Open Updater tab", callback: () => SettingsRouter.open("EquicordUpdater"), registrar: "Equicord" }, - { id: "openEquicordCloudSettings", label: "Open Cloud tab", callback: () => SettingsRouter.open("EquicordCloud"), registrar: "Equicord" }, - { id: "openBackupSettings", label: "Open Backup & Restore tab", callback: () => SettingsRouter.open("EquicordSettingsSync"), registrar: "Equicord" }, + { id: "openEquicordSettings", label: "Open Equicord tab", callback: async () => await openUserSettingsPanel("equicord_main"), registrar: "Equicord" }, + { id: "openPluginSettings", label: "Open Plugin tab", callback: () => openUserSettingsPanel("equicord_plugins"), registrar: "Equicord" }, + { id: "openThemesSettings", label: "Open Themes tab", callback: () => openUserSettingsPanel("equicord_themes"), registrar: "Equicord" }, + { id: "openUpdaterSettings", label: "Open Updater tab", callback: () => openUserSettingsPanel("equicord_updater"), registrar: "Equicord" }, + { id: "openEquicordCloudSettings", label: "Open Cloud tab", callback: () => openUserSettingsPanel("equicord_cloud"), registrar: "Equicord" }, + { id: "openBackupSettings", label: "Open Backup & Restore tab", callback: () => openUserSettingsPanel("equicord_backup_restore"), registrar: "Equicord" }, { id: "restartClient", label: "Restart Client", callback: () => relaunch(), registrar: "Equicord" }, { id: "openQuickCSSFile", label: "Open Quick CSS File", callback: () => VencordNative.quickCss.openEditor(), registrar: "Equicord" }, { id: "openSettingsFolder", label: "Open Settings Folder", callback: async () => showItemInFolder(await VencordNative.settings.getSettingsDir()), registrar: "Equicord" }, @@ -140,7 +140,7 @@ export const actions: ButtonAction[] = [ permanent: true, noPersist: true, onClick() { - SettingsRouter.open("EquicordUpdater"); + openUserSettingsPanel("equicord_updater"); } }), 10_000); } else { diff --git a/src/equicordplugins/keyboardNavigation/index.tsx b/src/equicordplugins/keyboardNavigation/index.tsx index 00405614f..75bb65d7e 100644 --- a/src/equicordplugins/keyboardNavigation/index.tsx +++ b/src/equicordplugins/keyboardNavigation/index.tsx @@ -9,7 +9,7 @@ import { classNameFactory } from "@api/Styles"; import { Devs } from "@utils/constants"; import { closeAllModals } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { SettingsRouter, useState } from "@webpack/common"; +import { openUserSettingsPanel, useState } from "@webpack/common"; import { registerAction } from "./commands"; import { openCommandPalette } from "./components/CommandPalette"; @@ -94,12 +94,14 @@ export default definePlugin({ start() { document.addEventListener("keydown", this.event); - registerAction({ - id: "openDevSettings", - label: "Open Dev tab", - callback: () => SettingsRouter.open("EquicordPatchHelper"), - registrar: "Equicord" - }); + if (IS_DEV) { + registerAction({ + id: "openDevSettings", + label: "Open Dev tab", + callback: () => openUserSettingsPanel("equicord_patch_helper"), + registrar: "Equicord" + }); + } }, stop() { diff --git a/src/equicordplugins/themeLibrary/index.tsx b/src/equicordplugins/themeLibrary/index.tsx index 17edca5c3..380ebcc5f 100644 --- a/src/equicordplugins/themeLibrary/index.tsx +++ b/src/equicordplugins/themeLibrary/index.tsx @@ -8,7 +8,7 @@ import { ColorPaletteIcon } from "@components/Icons"; import SettingsPlugin from "@plugins/_core/settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { SettingsRouter } from "@webpack/common"; +import { openUserSettingsPanel } from "@webpack/common"; import { settings } from "./utils/settings"; @@ -19,7 +19,7 @@ export default definePlugin({ settings, toolboxActions: { "Open Theme Library": () => { - SettingsRouter.open("ThemeLibrary"); + openUserSettingsPanel("theme_library"); }, }, diff --git a/src/plugins/webKeybinds.web/index.ts b/src/plugins/webKeybinds.web/index.ts index 6c69cb470..8ee938230 100644 --- a/src/plugins/webKeybinds.web/index.ts +++ b/src/plugins/webKeybinds.web/index.ts @@ -19,7 +19,7 @@ import { Devs, IS_MAC } from "@utils/constants"; import definePlugin from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { ComponentDispatch, FluxDispatcher, NavigationRouter, SelectedGuildStore, SettingsRouter } from "@webpack/common"; +import { ComponentDispatch, FluxDispatcher, NavigationRouter, openUserSettingsPanel, SelectedGuildStore } from "@webpack/common"; const KeyBinds = findByPropsLazy("JUMP_TO_GUILD", "SERVER_NEXT"); @@ -55,7 +55,7 @@ export default definePlugin({ break; case ",": e.preventDefault(); - SettingsRouter.open("My Account"); + openUserSettingsPanel("my_account"); break; default: if (e.key >= "1" && e.key <= "9") {