fix(settings): handle default device labels and empty device lists

This commit is contained in:
Vlad Gerasimov 2025-08-09 08:21:43 +04:00
parent 46d28a0616
commit 24e0319256
3 changed files with 8 additions and 8 deletions

View file

@ -1,7 +1,7 @@
const ResetIcon = () => {
return (
<svg fill="none" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><g stroke="#de689e" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="m13.5 8.5h3v-3"/><path d="m13.775 14c-.7863.7419-1.7737 1.2356-2.8389 1.4196-1.06527.1839-2.16109.0498-3.15057-.3855s-1.82875-1.1525-2.41293-2.0621c-.58419-.9095-.88739-1.9711-.87172-3.05197.01567-1.08089.34952-2.13319.95982-3.02543.61031-.89224 1.47001-1.58485 2.4717-1.99129s2.1009-.50868 3.1604-.29396c1.0595.21473 2.0322.7369 2.7965 1.50127l2.6107 2.38938"/></g></svg>
<svg fill="none" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><g stroke="#de689e" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.5"><path d="m13.5 8.5h3v-3"/><path d="m13.775 14c-.7863.7419-1.7737 1.2356-2.8389 1.4196-1.06527.1839-2.16109.0498-3.15057-.3855s-1.82875-1.1525-2.41293-2.0621c-.58419-.9095-.88739-1.9711-.87172-3.05197.01567-1.08089.34952-2.13319.95982-3.02543.61031-.89224 1.47001-1.58485 2.4717-1.99129s2.1009-.50868 3.1604-.29396c1.0595.21473 2.0322.7369 2.7965 1.50127l2.6107 2.38938"/></g></svg>
);
};

View file

@ -23,7 +23,8 @@ export const MicrophoneSelector: React.FC<MicrophoneSelectorProps> = 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<MicrophoneSelectorProps> = 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}
/>
<ResetButton

View file

@ -23,8 +23,7 @@ export const OutputDeviceSelector: React.FC<OutputDeviceSelectorProps> = 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<OutputDeviceSelectorProps> = 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}
/>
<ResetButton