Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SharedVideoButton.ts 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconPlay } from '../../../base/icons/svg';
  5. import { getLocalParticipant } from '../../../base/participants/functions';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import { toggleSharedVideo } from '../../actions';
  8. import { isSharingStatus } from '../../functions';
  9. interface IProps extends AbstractButtonProps {
  10. /**
  11. * Whether or not the button is disabled.
  12. */
  13. _isDisabled: boolean;
  14. /**
  15. * Whether or not the local participant is sharing a video.
  16. */
  17. _sharingVideo: boolean;
  18. }
  19. /**
  20. * Implements an {@link AbstractButton} to open the user documentation in a new window.
  21. */
  22. class SharedVideoButton extends AbstractButton<IProps> {
  23. accessibilityLabel = 'toolbar.accessibilityLabel.sharedvideo';
  24. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.stopSharedVideo';
  25. icon = IconPlay;
  26. label = 'toolbar.sharedvideo';
  27. toggledLabel = 'toolbar.stopSharedVideo';
  28. tooltip = 'toolbar.sharedvideo';
  29. toggledTooltip = 'toolbar.stopSharedVideo';
  30. /**
  31. * Handles clicking / pressing the button, and opens a new dialog.
  32. *
  33. * @private
  34. * @returns {void}
  35. */
  36. _handleClick() {
  37. this._doToggleSharedVideo();
  38. }
  39. /**
  40. * Indicates whether this button is in toggled state or not.
  41. *
  42. * @override
  43. * @protected
  44. * @returns {boolean}
  45. */
  46. _isToggled() {
  47. return this.props._sharingVideo;
  48. }
  49. /**
  50. * Indicates whether this button is disabled or not.
  51. *
  52. * @override
  53. * @protected
  54. * @returns {boolean}
  55. */
  56. _isDisabled() {
  57. return this.props._isDisabled;
  58. }
  59. /**
  60. * Dispatches an action to toggle video sharing.
  61. *
  62. * @private
  63. * @returns {void}
  64. */
  65. _doToggleSharedVideo() {
  66. this.props.dispatch(toggleSharedVideo());
  67. }
  68. }
  69. /**
  70. * Maps part of the Redux state to the props of this component.
  71. *
  72. * @param {Object} state - The Redux state.
  73. * @private
  74. * @returns {IProps}
  75. */
  76. function _mapStateToProps(state: IReduxState) {
  77. const { ownerId, status: sharedVideoStatus } = state['features/shared-video'];
  78. const localParticipantId = getLocalParticipant(state)?.id;
  79. const isSharing = isSharingStatus(sharedVideoStatus ?? '');
  80. return {
  81. _isDisabled: isSharing && ownerId !== localParticipantId,
  82. _sharingVideo: isSharing
  83. };
  84. }
  85. export default translate(connect(_mapStateToProps)(SharedVideoButton));