Merge pull request #3113 from matrix-org/bwindels/mediadeviceslabels

Provide default name if device label is missing
This commit is contained in:
Bruno Windels 2019-06-18 16:44:43 +00:00 committed by GitHub
commit bb97653455
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -100,7 +100,17 @@ export default class VoiceUserSettingsTab extends React.Component {
};
_renderDeviceOptions(devices, category) {
return devices.map((d) => <option key={`${category}-${d.deviceId}`} value={d.deviceId}>{d.label}</option>);
return devices.map((d) => {
let label = d.label;
if (!label) {
switch (d.kind) {
case "audioinput": label = _t("Unnamed microphone"); break;
case "audiooutput": label = _t("Unnamed audio output"); break;
case "videoinput": label = _t("Unnamed camera"); break;
}
}
return (<option key={`${category}-${d.deviceId}`} value={d.deviceId}>{label}</option>);
});
}
render() {