您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AskUnmuteButton.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @flow
  2. import { approveParticipant } from '../../../av-moderation/actions';
  3. import { isSupported } from '../../../av-moderation/functions';
  4. import { translate } from '../../../base/i18n';
  5. import { IconMic, IconVideo } from '../../../base/icons';
  6. import { MEDIA_TYPE } from '../../../base/media';
  7. import { getParticipantById, isLocalParticipantModerator } from '../../../base/participants';
  8. import { connect } from '../../../base/redux';
  9. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  10. import { isForceMuted } from '../../../participants-pane/functions';
  11. export type Props = AbstractButtonProps & {
  12. /**
  13. * The redux {@code dispatch} function.
  14. */
  15. dispatch: Function,
  16. /**
  17. * Whether or not the participant is audio force muted.
  18. */
  19. isAudioForceMuted: boolean,
  20. /**
  21. * Whether or not the participant is video force muted.
  22. */
  23. isVideoForceMuted: boolean,
  24. /**
  25. * The ID of the participant object that this button is supposed to
  26. * ask to unmute.
  27. */
  28. participantID: string
  29. };
  30. /**
  31. * An abstract remote video menu button which asks the remote participant to unmute.
  32. */
  33. class AskUnmuteButton extends AbstractButton<Props, *> {
  34. accessibilityLabel = 'participantsPane.actions.askUnmute';
  35. icon = IconMic;
  36. label = 'participantsPane.actions.askUnmute';
  37. /**
  38. * Gets the current label.
  39. *
  40. * @returns {string}
  41. */
  42. _getLabel() {
  43. const { isAudioForceMuted, isVideoForceMuted } = this.props;
  44. if (!isAudioForceMuted && isVideoForceMuted) {
  45. return 'participantsPane.actions.allowVideo';
  46. }
  47. return this.label;
  48. }
  49. /**
  50. * Gets the current icon.
  51. *
  52. * @returns {string}
  53. */
  54. _getIcon() {
  55. const { isAudioForceMuted, isVideoForceMuted } = this.props;
  56. if (!isAudioForceMuted && isVideoForceMuted) {
  57. return IconVideo;
  58. }
  59. return this.icon;
  60. }
  61. /**
  62. * Handles clicking / pressing the button, and asks the participant to unmute.
  63. *
  64. * @private
  65. * @returns {void}
  66. */
  67. _handleClick() {
  68. const { dispatch, participantID } = this.props;
  69. dispatch(approveParticipant(participantID));
  70. }
  71. }
  72. /**
  73. * Maps part of the Redux state to the props of this component.
  74. *
  75. * @param {Object} state - The Redux state.
  76. * @param {Object} ownProps - Properties of component.
  77. * @returns {Props}
  78. */
  79. function mapStateToProps(state, ownProps) {
  80. const { participantID } = ownProps;
  81. const participant = getParticipantById(state, participantID);
  82. return {
  83. isAudioForceMuted: isForceMuted(participant, MEDIA_TYPE.AUDIO, state),
  84. isVideoForceMuted: isForceMuted(participant, MEDIA_TYPE.VIDEO, state),
  85. visible: isLocalParticipantModerator(state) && isSupported()
  86. };
  87. }
  88. export default translate(connect(mapStateToProps)(AskUnmuteButton));