| | |
| | | let showOnboarding = $state(false) |
| | | |
| | | onMount(() => { |
| | | const offEvents: Array<() => void> = [] |
| | | |
| | | Call.ByName('voicesnap/services.ConfigService.GetLanguageSettings').then((settings: any) => { |
| | | applyLanguageSettings(settings) |
| | | }).catch(() => { |
| | | languageReady = true |
| | | }) |
| | | |
| | | Events.On('indicator:show', (ev: any) => { |
| | | offEvents.push(Events.On('indicator:show', (ev: any) => { |
| | | indicatorVisible.set(true) |
| | | if (ev?.data?.status) { |
| | | indicatorStatus.set(ev.data.status) |
| | | } |
| | | }) |
| | | })) |
| | | |
| | | Events.On('indicator:hide', () => { |
| | | offEvents.push(Events.On('indicator:hide', () => { |
| | | indicatorVisible.set(false) |
| | | }) |
| | | })) |
| | | |
| | | Events.On('indicator:status', (ev: any) => { |
| | | offEvents.push(Events.On('indicator:status', (ev: any) => { |
| | | const data = ev?.data |
| | | if (data?.status) { |
| | | indicatorStatus.set(data.status) |
| | | } |
| | | if (data?.hotkeyName) { |
| | | if (typeof data?.hotkeyName === 'string') { |
| | | hotkeyName.set(data.hotkeyName) |
| | | } |
| | | }) |
| | | })) |
| | | |
| | | Events.On('indicator:volume', (ev: any) => { |
| | | offEvents.push(Events.On('indicator:volume', (ev: any) => { |
| | | indicatorVolume.set(ev?.data ?? 0) |
| | | }) |
| | | })) |
| | | |
| | | Events.On('engine:status', (ev: any) => { |
| | | offEvents.push(Events.On('engine:status', (ev: any) => { |
| | | const data = ev?.data |
| | | if (data?.status) { |
| | | engineStatus.set(data.status as any) |
| | |
| | | if (data?.hardwareInfo) { |
| | | engineHardwareInfo.set(data.hardwareInfo) |
| | | } |
| | | }) |
| | | })) |
| | | |
| | | Events.On('device:changed', (ev: any) => { |
| | | offEvents.push(Events.On('device:changed', (ev: any) => { |
| | | if (ev?.data?.name) { |
| | | deviceName.set(ev.data.name) |
| | | } |
| | | }) |
| | | })) |
| | | |
| | | Events.On('update:available', (ev: any) => { |
| | | offEvents.push(Events.On('update:available', (ev: any) => { |
| | | const data = ev?.data as UpdateInfo |
| | | updateAvailable.set(data) |
| | | showUpdateDialog = true |
| | | }) |
| | | })) |
| | | |
| | | window.addEventListener('hashchange', () => { |
| | | const onHashChange = () => { |
| | | isIndicatorRoute = window.location.hash === '#/indicator' |
| | | }) |
| | | } |
| | | window.addEventListener('hashchange', onHashChange) |
| | | |
| | | // Query engine status on mount (events emitted before frontend load are lost) |
| | | Call.ByName('voicesnap/services.EngineService.GetStatus').then((data: any) => { |
| | |
| | | |
| | | refreshCurrentModelAvailability() |
| | | |
| | | // Load actual hotkey name from backend (store default is generic "Ctrl") |
| | | // Load actual hotkey name from backend; an empty name means no trigger key is set yet. |
| | | Call.ByName('voicesnap/services.HotkeyService.GetHotkeyName').then((name: any) => { |
| | | if (name) { |
| | | if (typeof name === 'string') { |
| | | hotkeyName.set(name) |
| | | } |
| | | }) |
| | | |
| | | return () => { |
| | | for (const off of offEvents) off() |
| | | window.removeEventListener('hashchange', onHashChange) |
| | | } |
| | | }) |
| | | |
| | | function applyLanguageSettings(settings: any) { |