Ariver
2026-07-06 ac1d4fd8ef875312d11acd4e4e5935ced542c227
C1.source/privatevoice.src/frontend/src/components/settings/GeneralPage.svelte
@@ -1,4 +1,5 @@
<script lang="ts">
  import { onDestroy } from 'svelte'
  import { Call } from '@wailsio/runtime'
  import ToggleSwitch from '../shared/ToggleSwitch.svelte'
  import { t } from '../../lib/i18n'
@@ -26,6 +27,7 @@
  let hintText = $state('')
  let devices = $state<InputDevice[]>([])
  let showDeviceDropdown = $state(false)
  let activeKeyHandler: ((e: KeyboardEvent) => void) | null = null
  const unsub1 = autoHide.subscribe(v => { autoHideVal = v })
  const unsub2 = startAtLogin.subscribe(v => { startAtLoginVal = v })
@@ -36,6 +38,11 @@
  const unsub7 = soundFeedback.subscribe(v => { soundFeedbackVal = v })
  const unsub8 = copyToClipboard.subscribe(v => { copyToClipboardVal = v })
  const unsub9 = hotkeyMode.subscribe(v => { hotkeyModeVal = v })
  onDestroy(() => {
    unsub1(); unsub2(); unsub3(); unsub4(); unsub5(); unsub6(); unsub7(); unsub8(); unsub9()
    clearHotkeyCapture()
  })
  // Load actual device name from backend on mount
  async function loadDeviceName() {
@@ -160,6 +167,7 @@
  }
  async function startRecordingHotkey() {
    clearHotkeyCapture()
    isRecording = true
    hintText = t('hotkeys.pressAnyKey')
@@ -191,13 +199,25 @@
          } catch {}
        })()
        document.removeEventListener('keydown', onKey)
        clearHotkeyCapture()
      }
    }
    activeKeyHandler = onKey
    document.addEventListener('keydown', onKey)
  }
  function clearHotkeyCapture() {
    if (activeKeyHandler) {
      document.removeEventListener('keydown', activeKeyHandler)
      activeKeyHandler = null
    }
    if (isRecording) {
      isRecording = false
      void Call.ByName('voicesnap/services.HotkeyService.StopRecordingHotkey').catch(() => {})
    }
  }
  function mapKeyToVK(e: KeyboardEvent): number {
    switch (e.key) {
      case 'Control': return e.location === 1 ? 0xA2 : e.location === 2 ? 0xA3 : 0x11