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
|
|
|
|
|
|
|
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';
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Popup with audio settings.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
function AudioSettingsPopup({
|
|
|
|
children,
|
|
|
|
currentMicDeviceId,
|
|
|
|
currentOutputDeviceId,
|
|
|
|
isOpen,
|
|
|
|
microphoneDevices,
|
|
|
|
setAudioInputDevice,
|
|
|
|
setAudioOutputDevice,
|
|
|
|
onClose,
|
|
|
|
outputDevices
|
|
|
|
}: Props) {
|
|
|
|
return (
|
|
|
|
<div className = 'audio-preview'>
|
|
|
|
<InlineDialog
|
|
|
|
content = { <AudioSettingsContent
|
|
|
|
currentMicDeviceId = { currentMicDeviceId }
|
|
|
|
currentOutputDeviceId = { currentOutputDeviceId }
|
|
|
|
microphoneDevices = { microphoneDevices }
|
|
|
|
outputDevices = { outputDevices }
|
|
|
|
setAudioInputDevice = { setAudioInputDevice }
|
|
|
|
setAudioOutputDevice = { setAudioOutputDevice } /> }
|
|
|
|
isOpen = { isOpen }
|
|
|
|
onClose = { onClose }
|
|
|
|
position = 'top left'>
|
|
|
|
{children}
|
|
|
|
</InlineDialog>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
currentMicDeviceId: getCurrentMicDeviceId(state),
|
|
|
|
currentOutputDeviceId: getCurrentOutputDeviceId(state),
|
|
|
|
isOpen: getAudioSettingsVisibility(state),
|
|
|
|
microphoneDevices: getAudioInputDeviceData(state),
|
|
|
|
outputDevices: getAudioOutputDeviceData(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|