You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AskUnmuteButton.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // @flow
  2. import { approveParticipant } from '../../../av-moderation/actions';
  3. import { translate } from '../../../base/i18n';
  4. import { IconMicrophone } from '../../../base/icons';
  5. import { MEDIA_TYPE } from '../../../base/media';
  6. import { getParticipantById, isLocalParticipantModerator } from '../../../base/participants';
  7. import { connect } from '../../../base/redux';
  8. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  9. import { isForceMuted } from '../../../participants-pane/functions';
  10. export type Props = AbstractButtonProps & {
  11. /**
  12. * The redux {@code dispatch} function.
  13. */
  14. dispatch: Function,
  15. /**
  16. * The ID of the participant object that this button is supposed to
  17. * ask to unmute.
  18. */
  19. participantID: string,
  20. };
  21. /**
  22. * An abstract remote video menu button which asks the remote participant to unmute.
  23. */
  24. class AskUnmuteButton extends AbstractButton<Props, *> {
  25. accessibilityLabel = 'participantsPane.actions.askUnmute';
  26. icon = IconMicrophone;
  27. label = 'participantsPane.actions.askUnmute';
  28. /**
  29. * Handles clicking / pressing the button, and asks the participant to unmute.
  30. *
  31. * @private
  32. * @returns {void}
  33. */
  34. _handleClick() {
  35. const { dispatch, participantID } = this.props;
  36. dispatch(approveParticipant(participantID));
  37. }
  38. }
  39. /**
  40. * Maps part of the Redux state to the props of this component.
  41. *
  42. * @param {Object} state - The Redux state.
  43. * @param {Object} ownProps - Properties of component.
  44. * @returns {Props}
  45. */
  46. function mapStateToProps(state, ownProps) {
  47. const { participantID } = ownProps;
  48. const participant = getParticipantById(state, participantID);
  49. return {
  50. visible: isLocalParticipantModerator(state)
  51. && (isForceMuted(participant, MEDIA_TYPE.AUDIO, state)
  52. || isForceMuted(participant, MEDIA_TYPE.VIDEO, state))
  53. };
  54. }
  55. export default translate(connect(mapStateToProps)(AskUnmuteButton));