Prevent empty device labels in audio preview

Fixes: #324
Signed-off-by: Johannes Marbach <johannesm@element.io>
This commit is contained in:
Johannes Marbach 2022-07-07 13:32:23 +02:00
parent 4dcec504ca
commit e8d99e15f7

View File

@ -53,8 +53,12 @@ export function AudioPreview({
onSelectionChange={setAudioInput}
className={styles.inputField}
>
{audioInputs.map(({ deviceId, label }) => (
<Item key={deviceId}>{label}</Item>
{audioInputs.map(({ deviceId, label }, index) => (
<Item key={deviceId}>
{!!label && label.trim().length > 0
? label
: `Microphone ${index + 1}`}
</Item>
))}
</SelectInput>
{audioOutputs.length > 0 && (
@ -64,8 +68,12 @@ export function AudioPreview({
onSelectionChange={setAudioOutput}
className={styles.inputField}
>
{audioOutputs.map(({ deviceId, label }) => (
<Item key={deviceId}>{label}</Item>
{audioOutputs.map(({ deviceId, label }, index) => (
<Item key={deviceId}>
{!!label && label.trim().length > 0
? label
: `Speaker ${index + 1}`}
</Item>
))}
</SelectInput>
)}