fix(visualizer): sync state and re-subscribe from audio device load
- Broaden audio import errors from ImportError to Exception, log at warning - Move visualizer WS re-subscription into loadAudioDevices() so it runs after availability is confirmed from the API - Show/hide the visualizer toggle button based on fetched availability
This commit is contained in:
@@ -485,7 +485,20 @@ export async function loadAudioDevices() {
|
||||
});
|
||||
_audioDeviceIconSelect.setValue(select.value, false);
|
||||
|
||||
// Sync visualizerAvailable from the fetched status so that
|
||||
// applyVisualizerMode() and the toggle button are consistent.
|
||||
visualizerAvailable = status.available;
|
||||
const btn = document.getElementById('visualizerToggle');
|
||||
if (btn) btn.style.display = visualizerAvailable ? '' : 'none';
|
||||
|
||||
updateAudioDeviceStatus(status);
|
||||
|
||||
// Re-subscribe the WebSocket if the user had the visualizer enabled.
|
||||
if (visualizerEnabled && visualizerAvailable) {
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(JSON.stringify({ type: 'enable_visualizer' }));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
section.style.display = 'none';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user