/* * Vesktop, a desktop app aiming to give you a snappier Discord Experience * Copyright (c) 2026 Vendicated and Vesktop contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import "./ShortcutSettings.css"; import { BaseText, Button, Card, DeleteIcon, Switch } from "@vencord/types/components"; import { classNameFactory, identity, ModalCloseButton, ModalContent, ModalHeader, ModalRoot, ModalSize, openModal } from "@vencord/types/utils"; import { React, Select, useState } from "@vencord/types/webpack/common"; import { SettingsComponent } from "renderer/components/settings/Settings"; import { onIpcCommand } from "renderer/ipcCommands"; import { reactiveValue } from "renderer/reactiveState"; import { Settings } from "renderer/settings"; import { IpcCommands } from "shared/IpcEvents"; import { recordKeybind } from "./recordKeybind"; const cl = classNameFactory("vcd-shortcuts-"); const ShortcutActions = { unassigned: "Unassigned", toggleMute: "Toggle Mute", toggleDeafen: "Toggle Deafen", toggleStreamerMode: "Toggle Streamer Mode", disconnectFromVoiceChannel: "Disconnect from VC" } as const; export type ShortcutAction = keyof typeof ShortcutActions; const shortcutStatus = reactiveValue(true); onIpcCommand(IpcCommands.KEY_BINDS_SET_STATUS, status => (shortcutStatus.value = status)); export interface KeyBind { id: string; enabled: boolean; action: ShortcutAction; key: string; } function KeyBindGroup({ keyBind, setKeyBind, deleteKeyBind }: { keyBind: KeyBind; setKeyBind(keyBind: KeyBind): void; deleteKeyBind(): void; }) { const [isRecording, setIsRecording] = useState(false); const [abortController, setAbortController] = useState(null); const actionId = React.useId(); const keyId = React.useId(); return (
Action Keybind {/* @ts-expect-error incorrect type for aria-labelledby */}
setKeyBind({ ...keyBind, enabled: v })} /> ); } export function KeyBindSettings() { const [keyBinds, setKeyBinds] = useState(Settings.store.keyBinds ?? []); const shortcutsStatus = shortcutStatus.use(); return (
{shortcutsStatus === false && ( Some of your keybinds failed to register. )} {keyBinds.map((keyBind, index) => ( { const newKeyBinds = [...keyBinds]; newKeyBinds[index] = newKeyBind; setKeyBinds(newKeyBinds); Settings.store.keyBinds = newKeyBinds; }} deleteKeyBind={() => { const newKeyBinds = keyBinds.filter((_, i) => i !== index); setKeyBinds(newKeyBinds); Settings.store.keyBinds = newKeyBinds; }} /> ))}
); } export function openKeybindsModal() { openModal(props => ( Keybinds )); } export const KeybindsButton: SettingsComponent = () => { return ; };