Revert voodoo

pull/21833/head
Michael Telatynski 2017-06-02 00:26:31 +01:00
parent 4976cbb424
commit 0bafd6458a
3 changed files with 11 additions and 31 deletions

View File

@ -53,36 +53,12 @@ export default {
// }); // });
}, },
_findDefault: function(devices) {
return devices.some((device) => device.deviceId === 'default') ? 'default' : undefined;
},
setAudioInputDefault: async function() {
const devices = await this.getDevices();
const audioDefault = this._findDefault(devices.audioinput);
this._setAudioInput(audioDefault);
},
setAudioInput: function(deviceId) { setAudioInput: function(deviceId) {
this[deviceId === 'default' ? 'setAudioInputDefault' : '_setAudioInput'](deviceId);
},
_setAudioInput: function(deviceId) {
UserSettingsStore.setLocalSetting('webrtc_audioinput', deviceId); UserSettingsStore.setLocalSetting('webrtc_audioinput', deviceId);
Matrix.setMatrixCallAudioInput(deviceId); Matrix.setMatrixCallAudioInput(deviceId);
}, },
setVideoInputDefault: async function() {
const devices = await this.getDevices();
const videoDefault = this._findDefault(devices.videoinput);
this._setVideoInput(videoDefault);
},
setVideoInput: function(deviceId) { setVideoInput: function(deviceId) {
this[deviceId === 'default' ? 'setVideoInputDefault' : '_setVideoInput'](deviceId);
},
_setVideoInput: function(deviceId) {
UserSettingsStore.setLocalSetting('webrtc_videoinput', deviceId); UserSettingsStore.setLocalSetting('webrtc_videoinput', deviceId);
Matrix.setMatrixCallVideoInput(deviceId); Matrix.setMatrixCallVideoInput(deviceId);
}, },

View File

@ -952,21 +952,24 @@ module.exports = React.createClass({
let webcamDropdown = <p>{_t('No Webcams detected')}</p>; let webcamDropdown = <p>{_t('No Webcams detected')}</p>;
const defaultOption = { const defaultOption = {
deviceId: 'default', deviceId: undefined,
label: _t('Default Device'), label: _t('Default Device'),
}; };
const audioInputs = this.state.mediaDevices.audioinput.slice(0); const audioInputs = this.state.mediaDevices.audioinput.slice(0);
if (audioInputs.length > 0) { if (audioInputs.length > 0) {
let defaultInput;
if (!audioInputs.some((input) => input.deviceId === 'default')) { if (!audioInputs.some((input) => input.deviceId === 'default')) {
audioInputs.unshift(defaultOption); audioInputs.unshift(defaultOption);
} else {
defaultInput = 'default';
} }
microphoneDropdown = <div> microphoneDropdown = <div>
<h4>{_t('Microphone')}</h4> <h4>Microphone</h4>
<Dropdown <Dropdown
className="mx_UserSettings_webRtcDevices_dropdown" className="mx_UserSettings_webRtcDevices_dropdown"
value={this.state.activeAudioInput || 'default'} value={this.state.activeAudioInput || defaultInput}
onOptionChange={this._setAudioInput}> onOptionChange={this._setAudioInput}>
{this._mapWebRtcDevicesToSpans(audioInputs)} {this._mapWebRtcDevicesToSpans(audioInputs)}
</Dropdown> </Dropdown>
@ -975,15 +978,18 @@ module.exports = React.createClass({
const videoInputs = this.state.mediaDevices.videoinput.slice(0); const videoInputs = this.state.mediaDevices.videoinput.slice(0);
if (videoInputs.length > 0) { if (videoInputs.length > 0) {
let defaultInput;
if (!videoInputs.some((input) => input.deviceId === 'default')) { if (!videoInputs.some((input) => input.deviceId === 'default')) {
videoInputs.unshift(defaultOption); videoInputs.unshift(defaultOption);
} else {
defaultInput = 'default';
} }
webcamDropdown = <div> webcamDropdown = <div>
<h4>{_t('Camera')}</h4> <h4>Cameras</h4>
<Dropdown <Dropdown
className="mx_UserSettings_webRtcDevices_dropdown" className="mx_UserSettings_webRtcDevices_dropdown"
value={this.state.activeVideoInput || 'default'} value={this.state.activeVideoInput || defaultInput}
onOptionChange={this._setVideoInput}> onOptionChange={this._setVideoInput}>
{this._mapWebRtcDevicesToSpans(videoInputs)} {this._mapWebRtcDevicesToSpans(videoInputs)}
</Dropdown> </Dropdown>

View File

@ -136,8 +136,6 @@
"No media permissions": "No media permissions", "No media permissions": "No media permissions",
"You may need to manually permit Riot to access your microphone/webcam": "You may need to manually permit Riot to access your microphone/webcam", "You may need to manually permit Riot to access your microphone/webcam": "You may need to manually permit Riot to access your microphone/webcam",
"Default Device": "Default Device", "Default Device": "Default Device",
"Microphone": "Microphone",
"Cameras": "Cameras",
"Advanced": "Advanced", "Advanced": "Advanced",
"Algorithm": "Algorithm", "Algorithm": "Algorithm",
"Always show message timestamps": "Always show message timestamps", "Always show message timestamps": "Always show message timestamps",