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.

AbstractMuteRemoteParticipantsVideoDialog.ts 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { Component } from 'react';
  2. import { IState } from '../../app/types';
  3. import { rejectParticipantVideo } from '../../av-moderation/actions';
  4. import { isEnabledFromState } from '../../av-moderation/functions';
  5. import { MEDIA_TYPE } from '../../base/media/constants';
  6. // eslint-disable-next-line lines-around-comment
  7. // @ts-ignore
  8. import { muteRemote } from '../actions';
  9. /**
  10. * The type of the React {@code Component} props of
  11. * {@link AbstractMuteRemoteParticipantsVideoDialog}.
  12. */
  13. export type Props = {
  14. /**
  15. * The Redux dispatch function.
  16. */
  17. dispatch: Function;
  18. /**
  19. * Whether or not video moderation is on.
  20. */
  21. isVideoModerationOn: boolean;
  22. /**
  23. * The ID of the remote participant to be muted.
  24. */
  25. participantID: string;
  26. /**
  27. * Function to translate i18n labels.
  28. */
  29. t: Function;
  30. };
  31. /**
  32. * Abstract dialog to confirm a remote participant video ute action.
  33. *
  34. * @augments Component
  35. */
  36. export default class AbstractMuteRemoteParticipantsVideoDialog<P extends Props = Props, State=void>
  37. extends Component<P, State> {
  38. /**
  39. * Initializes a new {@code AbstractMuteRemoteParticipantsVideoDialog} instance.
  40. *
  41. * @param {Object} props - The read-only properties with which the new
  42. * instance is to be initialized.
  43. */
  44. constructor(props: P) {
  45. super(props);
  46. // Bind event handlers so they are only bound once per instance.
  47. this._onSubmit = this._onSubmit.bind(this);
  48. }
  49. /**
  50. * Handles the submit button action.
  51. *
  52. * @private
  53. * @returns {boolean} - True (to note that the modal should be closed).
  54. */
  55. _onSubmit() {
  56. const { dispatch, participantID } = this.props;
  57. dispatch(muteRemote(participantID, MEDIA_TYPE.VIDEO));
  58. dispatch(rejectParticipantVideo(participantID));
  59. return true;
  60. }
  61. }
  62. /**
  63. * Maps (parts of) the redux state to the associated
  64. * {@code AbstractDialogContainer}'s props.
  65. *
  66. * @param {IState} state - The redux state.
  67. * @private
  68. * @returns {Object}
  69. */
  70. export function abstractMapStateToProps(state: IState) {
  71. return {
  72. isVideoModerationOn: isEnabledFromState(MEDIA_TYPE.VIDEO, state)
  73. };
  74. }