2021-09-22 14:05:42 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { approveParticipant } from '../../../av-moderation/actions';
|
2021-10-25 11:40:42 +00:00
|
|
|
import { isSupported } from '../../../av-moderation/functions';
|
2021-09-22 14:05:42 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconMic, IconVideo } from '../../../base/icons';
|
2021-09-22 14:05:42 +00:00
|
|
|
import { MEDIA_TYPE } from '../../../base/media';
|
|
|
|
import { getParticipantById, isLocalParticipantModerator } from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
|
|
|
import { isForceMuted } from '../../../participants-pane/functions';
|
|
|
|
|
|
|
|
export type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2021-10-25 11:40:42 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the participant is audio force muted.
|
|
|
|
*/
|
|
|
|
isAudioForceMuted: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the participant is video force muted.
|
|
|
|
*/
|
|
|
|
isVideoForceMuted: boolean,
|
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
/**
|
|
|
|
* The ID of the participant object that this button is supposed to
|
|
|
|
* ask to unmute.
|
|
|
|
*/
|
2021-10-25 11:40:42 +00:00
|
|
|
participantID: string
|
2021-09-22 14:05:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstract remote video menu button which asks the remote participant to unmute.
|
|
|
|
*/
|
|
|
|
class AskUnmuteButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'participantsPane.actions.askUnmute';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconMic;
|
2021-09-22 14:05:42 +00:00
|
|
|
label = 'participantsPane.actions.askUnmute';
|
|
|
|
|
2021-10-25 11:40:42 +00:00
|
|
|
/**
|
|
|
|
* Gets the current label.
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
_getLabel() {
|
|
|
|
const { isAudioForceMuted, isVideoForceMuted } = this.props;
|
|
|
|
|
|
|
|
if (!isAudioForceMuted && isVideoForceMuted) {
|
|
|
|
return 'participantsPane.actions.allowVideo';
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.label;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current icon.
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
_getIcon() {
|
|
|
|
const { isAudioForceMuted, isVideoForceMuted } = this.props;
|
|
|
|
|
|
|
|
if (!isAudioForceMuted && isVideoForceMuted) {
|
2022-11-08 10:24:32 +00:00
|
|
|
return IconVideo;
|
2021-10-25 11:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.icon;
|
|
|
|
}
|
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and asks the participant to unmute.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
const { dispatch, participantID } = this.props;
|
|
|
|
|
|
|
|
dispatch(approveParticipant(participantID));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Object} ownProps - Properties of component.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
|
|
const { participantID } = ownProps;
|
|
|
|
const participant = getParticipantById(state, participantID);
|
|
|
|
|
|
|
|
return {
|
2021-10-25 11:40:42 +00:00
|
|
|
isAudioForceMuted: isForceMuted(participant, MEDIA_TYPE.AUDIO, state),
|
|
|
|
isVideoForceMuted: isForceMuted(participant, MEDIA_TYPE.VIDEO, state),
|
|
|
|
visible: isLocalParticipantModerator(state) && isSupported()
|
2021-09-22 14:05:42 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(mapStateToProps)(AskUnmuteButton));
|