2018-04-18 14:34:40 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-07-31 12:47:52 +00:00
|
|
|
import { toggleAudioOnly } from '../../../base/audio-only';
|
2021-03-19 07:17:37 +00:00
|
|
|
import { AUDIO_ONLY_BUTTON_ENABLED, getFeatureFlag } from '../../../base/flags';
|
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';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
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.
|
2021-03-19 07:17:37 +00:00
|
|
|
* @param {Object} ownProps - The properties explicitly passed to the component instance.
|
2018-04-18 14:34:40 +00:00
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _audioOnly: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
2021-03-19 07:17:37 +00:00
|
|
|
function _mapStateToProps(state, ownProps): Object {
|
2019-07-31 12:47:52 +00:00
|
|
|
const { enabled: audioOnly } = state['features/base/audio-only'];
|
2021-03-19 07:17:37 +00:00
|
|
|
const enabledInFeatureFlags = getFeatureFlag(state, AUDIO_ONLY_BUTTON_ENABLED, true);
|
|
|
|
const { visible = enabledInFeatureFlags } = ownProps;
|
2018-04-18 14:34:40 +00:00
|
|
|
|
|
|
|
return {
|
2021-03-19 07:17:37 +00:00
|
|
|
_audioOnly: Boolean(audioOnly),
|
|
|
|
visible
|
2018-04-18 14:34:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(AudioOnlyButton));
|