A free, open source, and extensible speech-to-text application that works completely offline.
fix(settings): handle default device labels and empty device lists
Vlad Gerasimov24e031925680
diff --git a/src/components/icons/ResetIcon.tsx b/src/components/icons/ResetIcon.tsxindex 09f2e46e..eb7db620 100644--- a/src/components/icons/ResetIcon.tsx+++ b/src/components/icons/ResetIcon.tsx@@ -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>);};diff --git a/src/components/settings/MicrophoneSelector.tsx b/src/components/settings/MicrophoneSelector.tsxindex dc9bccf8..f37ab388 100644--- a/src/components/settings/MicrophoneSelector.tsx+++ b/src/components/settings/MicrophoneSelector.tsx@@ -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}/><ResetButtondiff --git a/src/components/settings/OutputDeviceSelector.tsx b/src/components/settings/OutputDeviceSelector.tsxindex 156805e1..b0efd703 100644--- a/src/components/settings/OutputDeviceSelector.tsx+++ b/src/components/settings/OutputDeviceSelector.tsx@@ -23,8 +23,7 @@ export const OutputDeviceSelector: React.FC<OutputDeviceSelectorProps> = React.mrefreshOutputDevices,} = 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.moptions={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