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.1KB

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