2018-04-18 14:34:40 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-07-31 12:47:52 +00:00
|
|
|
import { toggleAudioOnly } from '../../../base/audio-only';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2019-08-30 16:39:06 +00:00
|
|
|
import { IconAudioOnly, IconAudioOnlyOff } from '../../../base/icons';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { AbstractButton } from '../../../base/toolbox';
|
|
|
|
import type { AbstractButtonProps } from '../../../base/toolbox';
|
2018-04-18 14:34:40 +00:00
|
|
|
|
2018-05-11 02:10:26 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link AudioOnlyButton}.
|
|
|
|
*/
|
2018-04-18 14:34:40 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the current conference is in audio only mode or not.
|
|
|
|
*/
|
|
|
|
_audioOnly: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
2018-05-10 23:01:55 +00:00
|
|
|
};
|
2018-04-18 14:34:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An implementation of a button for toggling the audio-only mode.
|
|
|
|
*/
|
|
|
|
class AudioOnlyButton extends AbstractButton<Props, *> {
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.audioOnly';
|
2019-08-30 16:39:06 +00:00
|
|
|
icon = IconAudioOnly;
|
2018-05-22 10:02:05 +00:00
|
|
|
label = 'toolbar.audioOnlyOn';
|
2019-08-30 16:39:06 +00:00
|
|
|
toggledIcon = IconAudioOnlyOff;
|
2018-05-22 10:02:05 +00:00
|
|
|
toggledLabel = 'toolbar.audioOnlyOff';
|
2018-04-18 14:34:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
*
|
2018-05-11 02:10:26 +00:00
|
|
|
* @override
|
|
|
|
* @protected
|
2018-04-18 14:34:40 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
this.props.dispatch(toggleAudioOnly());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-18 14:34:40 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._audioOnly;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
|
|
|
* {@code AudioOnlyButton} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _audioOnly: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object {
|
2019-07-31 12:47:52 +00:00
|
|
|
const { enabled: audioOnly } = state['features/base/audio-only'];
|
2018-04-18 14:34:40 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
_audioOnly: Boolean(audioOnly)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(AudioOnlyButton));
|