Add 1-second polling for DAC Passthrough badge updates

User requested faster badge color changes. Previously badge only updated
on mount or hover, causing 2+ second delays.

Solution: Poll hardware status every 1 second when DAC Passthrough is
enabled. This provides instant visual feedback without affecting playback:
- Only polls when dac_passthrough is true (conditional)
- Only reads hardware status (no playback impact)
- Cleanup on component unmount
- Fast enough for instant feedback, light enough for performance

Addresses user feedback: badge updates now appear instantly instead of
requiring hover or waiting multiple seconds.
This commit is contained in:
vicrodh committed 2026-01-17 17:31:37 -06:00
1 parent 89126446bb
commit 676d58af0f
1 file changed
+16 -1
+16 -1
View File
@@ -142,7 +142,22 @@
onMount(() => {
loadStatus();
// No polling - data is loaded once on mount and refreshed on hover
// Auto-refresh hardware status when DAC passthrough is active
// Fast polling (1s) for instant badge updates without needing hover
const pollInterval = setInterval(async () => {
// Only poll if DAC passthrough is enabled (otherwise wastes resources)
if (settings?.dac_passthrough) {
try {
hardwareStatus = await invoke<HardwareAudioStatus>('get_hardware_audio_status').catch(() => null);
} catch (err) {
// Silently fail - don't spam console
}
}
}, 1000); // 1 second - fast enough for instant feedback, light enough not to impact performance
// Cleanup on unmount
return () => clearInterval(pollInterval);
});
</script>