Settings 열기 속도 개선: 디바이스 비동기 로드 + 부팅 시 프리캐싱
- SettingsModal: 설정+핫키 먼저 로드 → 즉시 표시, 디바이스는 백그라운드 - bootstrap: 앱 부팅 시 getDevices() 미리 호출 → 캐싱 - 첫 번째 Settings 열기도 빠르게 (캐시 히트)
This commit is contained in:
parent
39eb8b20fe
commit
561502ec36
2 changed files with 15 additions and 5 deletions
|
|
@ -12,6 +12,7 @@ import { getTextInsertService } from './services/TextInsertService'
|
|||
import { getCustomInstructionService } from './services/CustomInstructionService'
|
||||
import { getSoundEffectService } from './services/SoundEffectService'
|
||||
import { getAutoLaunchService } from './services/AutoLaunchService'
|
||||
import { getAudioCaptureService } from './services/AudioCaptureService'
|
||||
import { initDatabase } from './db'
|
||||
import {
|
||||
createMainWindow,
|
||||
|
|
@ -118,6 +119,9 @@ async function initPopupWindows(): Promise<void> {
|
|||
preloadPopupWindows()
|
||||
setupHistoryPopupIPC()
|
||||
|
||||
// 오디오 디바이스 미리 캐싱 (Settings 열 때 즉시 반환)
|
||||
getAudioCaptureService().getDevices().catch(() => { /* 실패해도 무시 */ })
|
||||
|
||||
// Ctrl+Shift+V → 히스토리 팝업 토글
|
||||
globalShortcut.register('Ctrl+Shift+V', () => {
|
||||
if (isHistoryPopupVisible()) {
|
||||
|
|
|
|||
|
|
@ -199,15 +199,14 @@ export function SettingsModal({ open, onClose }: SettingsModalProps): React.Reac
|
|||
if (!open) return
|
||||
setLoading(true)
|
||||
|
||||
// 빠른 로드: 설정+핫키 먼저 (즉시 표시)
|
||||
Promise.all([
|
||||
window.electronAPI.config.getAll(),
|
||||
window.electronAPI.hotkey.getDictationShortcut(),
|
||||
window.electronAPI.hotkey.getHandsFreeShortcut(),
|
||||
window.electronAPI.hotkey.isEnabled(),
|
||||
window.electronAPI.audio.getDevices(),
|
||||
window.electronAPI.audio.getSelectedDevice(),
|
||||
])
|
||||
.then(([configResult, dictResult, hfResult, enabledResult, devicesResult, selectedResult]) => {
|
||||
.then(([configResult, dictResult, hfResult, enabledResult]) => {
|
||||
if (configResult.success) setConfig(configResult.data)
|
||||
if (dictResult.success && dictResult.data) setDictationBinding(dictResult.data)
|
||||
if (hfResult.success && hfResult.data) setHandsFreeBinding(hfResult.data)
|
||||
|
|
@ -215,10 +214,17 @@ export function SettingsModal({ open, onClose }: SettingsModalProps): React.Reac
|
|||
setHotkeyGlobalEnabled(enabledResult.data)
|
||||
setDictationEnabled(enabledResult.data)
|
||||
}
|
||||
if (devicesResult.success) setAudioDevices(devicesResult.data)
|
||||
if (selectedResult.success && selectedResult.data) setSelectedDeviceId(selectedResult.data)
|
||||
})
|
||||
.finally(() => setLoading(false))
|
||||
|
||||
// 느린 로드: 오디오 디바이스 (백그라운드, UI 블로킹 안 함)
|
||||
Promise.all([
|
||||
window.electronAPI.audio.getDevices(),
|
||||
window.electronAPI.audio.getSelectedDevice(),
|
||||
]).then(([devicesResult, selectedResult]) => {
|
||||
if (devicesResult.success) setAudioDevices(devicesResult.data)
|
||||
if (selectedResult.success && selectedResult.data) setSelectedDeviceId(selectedResult.data)
|
||||
})
|
||||
}, [open])
|
||||
|
||||
const updateConfig = useCallback((key: keyof AppConfig, value: AppConfig[keyof AppConfig]) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue