From 24e0319256800f8a4d25aebe658ca4922ef5f472 Mon Sep 17 00:00:00 2001 From: Vlad Gerasimov Date: Sat, 9 Aug 2025 08:21:43 +0400 Subject: [PATCH] fix(settings): handle default device labels and empty device lists --- src/components/icons/ResetIcon.tsx | 2 +- src/components/settings/MicrophoneSelector.tsx | 7 ++++--- src/components/settings/OutputDeviceSelector.tsx | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/icons/ResetIcon.tsx b/src/components/icons/ResetIcon.tsx index 09f2e46..eb7db62 100644 --- a/src/components/icons/ResetIcon.tsx +++ b/src/components/icons/ResetIcon.tsx @@ -1,7 +1,7 @@ const ResetIcon = () => { return ( - + ); }; diff --git a/src/components/settings/MicrophoneSelector.tsx b/src/components/settings/MicrophoneSelector.tsx index dc9bccf..f37ab38 100644 --- a/src/components/settings/MicrophoneSelector.tsx +++ b/src/components/settings/MicrophoneSelector.tsx @@ -23,7 +23,8 @@ export const MicrophoneSelector: React.FC = React.memo( refreshAudioDevices, } = useSettings(); - const selectedMicrophone = getSetting("selected_microphone") || "Default"; + const selectedMicrophone = getSetting("selected_microphone") === "default" ? "Default" : getSetting("selected_microphone") || "Default"; + const handleMicrophoneSelect = async (deviceName: string) => { await updateSetting("selected_microphone", deviceName); @@ -50,8 +51,8 @@ export const MicrophoneSelector: React.FC = React.memo( options={microphoneOptions} selectedValue={selectedMicrophone} onSelect={handleMicrophoneSelect} - placeholder={isLoading ? "Loading..." : "Select microphone..."} - disabled={isUpdating("selected_microphone") || isLoading} + placeholder={isLoading || audioDevices.length === 0 ? "Loading..." : "Select microphone..."} + disabled={isUpdating("selected_microphone") || isLoading || audioDevices.length === 0} onRefresh={refreshAudioDevices} /> = React.m refreshOutputDevices, } = useSettings(); - const selectedOutputDevice = - getSetting("selected_output_device") || "Default"; + const selectedOutputDevice = getSetting("selected_output_device") === "default" ? "Default" : getSetting("selected_output_device") || "Default"; const handleOutputDeviceSelect = async (deviceName: string) => { await updateSetting("selected_output_device", deviceName); @@ -51,8 +50,8 @@ export const OutputDeviceSelector: React.FC = React.m options={outputDeviceOptions} selectedValue={selectedOutputDevice} onSelect={handleOutputDeviceSelect} - placeholder={isLoading ? "Loading..." : "Select output device..."} - disabled={isUpdating("selected_output_device") || isLoading} + placeholder={isLoading || outputDevices.length === 0 ? "Loading..." : "Select output device..."} + disabled={isUpdating("selected_output_device") || isLoading || outputDevices.length === 0} onRefresh={refreshOutputDevices} />