mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 15:47:47 +00:00
The device selection initialization on the prejoin use case was handled like the welcome page. This was introducing issues with selecting the stored devices and not the ones used, enabling the device selection when it will fail and others.
66 lines
2.6 KiB
JavaScript
66 lines
2.6 KiB
JavaScript
import { createDeviceChangedEvent, sendAnalytics } from '../analytics';
|
|
import {
|
|
getDeviceLabelById,
|
|
setAudioInputDevice,
|
|
setAudioOutputDeviceId,
|
|
setVideoInputDevice
|
|
} from '../base/devices';
|
|
import { updateSettings } from '../base/settings';
|
|
|
|
import { getDeviceSelectionDialogProps } from './functions';
|
|
import logger from './logger';
|
|
|
|
/**
|
|
* Submits the settings related to device selection.
|
|
*
|
|
* @param {Object} newState - The new settings.
|
|
* @param {boolean} isDisplayedOnWelcomePage - Indicates whether the device selection dialog is displayed on the
|
|
* welcome page or not.
|
|
* @returns {Function}
|
|
*/
|
|
export function submitDeviceSelectionTab(newState, isDisplayedOnWelcomePage) {
|
|
return (dispatch, getState) => {
|
|
const currentState = getDeviceSelectionDialogProps(getState(), isDisplayedOnWelcomePage);
|
|
|
|
if (newState.selectedVideoInputId && (newState.selectedVideoInputId !== currentState.selectedVideoInputId)) {
|
|
dispatch(updateSettings({
|
|
userSelectedCameraDeviceId: newState.selectedVideoInputId,
|
|
userSelectedCameraDeviceLabel:
|
|
getDeviceLabelById(getState(), newState.selectedVideoInputId, 'videoInput')
|
|
}));
|
|
|
|
dispatch(setVideoInputDevice(newState.selectedVideoInputId));
|
|
}
|
|
|
|
if (newState.selectedAudioInputId && newState.selectedAudioInputId !== currentState.selectedAudioInputId) {
|
|
dispatch(updateSettings({
|
|
userSelectedMicDeviceId: newState.selectedAudioInputId,
|
|
userSelectedMicDeviceLabel:
|
|
getDeviceLabelById(getState(), newState.selectedAudioInputId, 'audioInput')
|
|
}));
|
|
|
|
dispatch(setAudioInputDevice(newState.selectedAudioInputId));
|
|
}
|
|
|
|
if (newState.selectedAudioOutputId
|
|
&& newState.selectedAudioOutputId
|
|
!== currentState.selectedAudioOutputId) {
|
|
sendAnalytics(createDeviceChangedEvent('audio', 'output'));
|
|
|
|
setAudioOutputDeviceId(
|
|
newState.selectedAudioOutputId,
|
|
dispatch,
|
|
true,
|
|
getDeviceLabelById(getState(), newState.selectedAudioOutputId, 'audioOutput'))
|
|
.then(() => logger.log('changed audio output device'))
|
|
.catch(err => {
|
|
logger.warn(
|
|
'Failed to change audio output device.',
|
|
'Default or previously set audio output device will',
|
|
' be used instead.',
|
|
err);
|
|
});
|
|
}
|
|
};
|
|
}
|