2020-03-30 14:17:18 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import InlineDialog from '@atlaskit/inline-dialog';
|
2020-05-20 10:57:03 +00:00
|
|
|
import React from 'react';
|
2020-03-30 14:17:18 +00:00
|
|
|
|
2022-01-11 16:08:36 +00:00
|
|
|
import { areAudioLevelsEnabled } from '../../../../base/config/functions';
|
2020-03-30 14:17:18 +00:00
|
|
|
import {
|
|
|
|
getAudioInputDeviceData,
|
|
|
|
getAudioOutputDeviceData,
|
2020-04-14 06:53:04 +00:00
|
|
|
setAudioInputDeviceAndUpdateSettings,
|
2020-03-30 14:17:18 +00:00
|
|
|
setAudioOutputDevice as setAudioOutputDeviceAction
|
|
|
|
} from '../../../../base/devices';
|
|
|
|
import { connect } from '../../../../base/redux';
|
2021-06-30 09:01:47 +00:00
|
|
|
import { SMALL_MOBILE_WIDTH } from '../../../../base/responsive-ui/constants';
|
2020-03-30 14:17:18 +00:00
|
|
|
import {
|
|
|
|
getCurrentMicDeviceId,
|
|
|
|
getCurrentOutputDeviceId
|
|
|
|
} from '../../../../base/settings';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { toggleAudioSettings } from '../../../actions';
|
|
|
|
import { getAudioSettingsVisibility } from '../../../functions';
|
|
|
|
|
|
|
|
import AudioSettingsContent, { type Props as AudioSettingsContentProps } from './AudioSettingsContent';
|
2020-03-30 14:17:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
type Props = AudioSettingsContentProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component's children (the audio button).
|
|
|
|
*/
|
|
|
|
children: React$Node,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag controlling the visibility of the popup.
|
|
|
|
*/
|
|
|
|
isOpen: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback executed when the popup closes.
|
|
|
|
*/
|
|
|
|
onClose: Function,
|
2021-06-30 09:01:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The popup placement enum value.
|
|
|
|
*/
|
|
|
|
popupPlacement: string
|
2020-03-30 14:17:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Popup with audio settings.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
function AudioSettingsPopup({
|
|
|
|
children,
|
|
|
|
currentMicDeviceId,
|
|
|
|
currentOutputDeviceId,
|
|
|
|
isOpen,
|
|
|
|
microphoneDevices,
|
|
|
|
setAudioInputDevice,
|
|
|
|
setAudioOutputDevice,
|
|
|
|
onClose,
|
2021-06-30 09:01:47 +00:00
|
|
|
outputDevices,
|
2022-01-11 16:08:36 +00:00
|
|
|
popupPlacement,
|
|
|
|
measureAudioLevels
|
2020-03-30 14:17:18 +00:00
|
|
|
}: Props) {
|
|
|
|
return (
|
|
|
|
<div className = 'audio-preview'>
|
|
|
|
<InlineDialog
|
|
|
|
content = { <AudioSettingsContent
|
|
|
|
currentMicDeviceId = { currentMicDeviceId }
|
|
|
|
currentOutputDeviceId = { currentOutputDeviceId }
|
2022-01-11 16:08:36 +00:00
|
|
|
measureAudioLevels = { measureAudioLevels }
|
2020-03-30 14:17:18 +00:00
|
|
|
microphoneDevices = { microphoneDevices }
|
|
|
|
outputDevices = { outputDevices }
|
|
|
|
setAudioInputDevice = { setAudioInputDevice }
|
|
|
|
setAudioOutputDevice = { setAudioOutputDevice } /> }
|
|
|
|
isOpen = { isOpen }
|
|
|
|
onClose = { onClose }
|
2021-06-30 09:01:47 +00:00
|
|
|
placement = { popupPlacement }>
|
2020-03-30 14:17:18 +00:00
|
|
|
{children}
|
|
|
|
</InlineDialog>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
2021-06-30 09:01:47 +00:00
|
|
|
const { clientWidth } = state['features/base/responsive-ui'];
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
return {
|
2021-06-30 09:01:47 +00:00
|
|
|
popupPlacement: clientWidth <= SMALL_MOBILE_WIDTH ? 'auto' : 'top-start',
|
2020-03-30 14:17:18 +00:00
|
|
|
currentMicDeviceId: getCurrentMicDeviceId(state),
|
|
|
|
currentOutputDeviceId: getCurrentOutputDeviceId(state),
|
|
|
|
isOpen: getAudioSettingsVisibility(state),
|
|
|
|
microphoneDevices: getAudioInputDeviceData(state),
|
2022-01-11 16:08:36 +00:00
|
|
|
outputDevices: getAudioOutputDeviceData(state),
|
|
|
|
measureAudioLevels: areAudioLevelsEnabled(state)
|
2020-03-30 14:17:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
onClose: toggleAudioSettings,
|
2020-04-14 06:53:04 +00:00
|
|
|
setAudioInputDevice: setAudioInputDeviceAndUpdateSettings,
|
2020-03-30 14:17:18 +00:00
|
|
|
setAudioOutputDevice: setAudioOutputDeviceAction
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AudioSettingsPopup);
|