Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

SharedVideoButton.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import type { Dispatch } from 'redux';
  4. import { VIDEO_SHARE_BUTTON_ENABLED } from '../../../base/flags/constants';
  5. import { getFeatureFlag } from '../../../base/flags/functions';
  6. import { translate } from '../../../base/i18n/functions';
  7. import { IconPlay } from '../../../base/icons/svg';
  8. import { getLocalParticipant } from '../../../base/participants/functions';
  9. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  10. import { toggleSharedVideo } from '../../actions.native';
  11. import { isSharingStatus } from '../../functions';
  12. /**
  13. * The type of the React {@code Component} props of {@link TileViewButton}.
  14. */
  15. type Props = AbstractButtonProps & {
  16. /**
  17. * Whether or not the button is disabled.
  18. */
  19. _isDisabled: boolean,
  20. /**
  21. * Whether or not the local participant is sharing a video.
  22. */
  23. _sharingVideo: boolean,
  24. /**
  25. * The redux {@code dispatch} function.
  26. */
  27. dispatch: Dispatch<any>
  28. };
  29. /**
  30. * Component that renders a toolbar button for toggling the tile layout view.
  31. *
  32. * @augments AbstractButton
  33. */
  34. class VideoShareButton extends AbstractButton<Props, *> {
  35. accessibilityLabel = 'toolbar.accessibilityLabel.sharedvideo';
  36. icon = IconPlay;
  37. label = 'toolbar.sharedvideo';
  38. toggledLabel = 'toolbar.stopSharedVideo';
  39. /**
  40. * Handles clicking / pressing the button.
  41. *
  42. * @override
  43. * @protected
  44. * @returns {void}
  45. */
  46. _handleClick() {
  47. this._doToggleSharedVideo();
  48. }
  49. /**
  50. * Indicates whether this button is in toggled state or not.
  51. *
  52. * @override
  53. * @protected
  54. * @returns {boolean}
  55. */
  56. _isToggled() {
  57. return this.props._sharingVideo;
  58. }
  59. /**
  60. * Indicates whether this button is disabled or not.
  61. *
  62. * @override
  63. * @protected
  64. * @returns {boolean}
  65. */
  66. _isDisabled() {
  67. return this.props._isDisabled;
  68. }
  69. /**
  70. * Dispatches an action to toggle video sharing.
  71. *
  72. * @private
  73. * @returns {void}
  74. */
  75. _doToggleSharedVideo() {
  76. this.props.dispatch(toggleSharedVideo());
  77. }
  78. }
  79. /**
  80. * Maps part of the Redux state to the props of this component.
  81. *
  82. * @param {Object} state - The Redux state.
  83. * @param {Object} ownProps - The properties explicitly passed to the component instance.
  84. * @private
  85. * @returns {Props}
  86. */
  87. function _mapStateToProps(state, ownProps): Object {
  88. const { ownerId, status: sharedVideoStatus } = state['features/shared-video'];
  89. const localParticipantId = getLocalParticipant(state).id;
  90. const enabled = getFeatureFlag(state, VIDEO_SHARE_BUTTON_ENABLED, true);
  91. const { visible = enabled } = ownProps;
  92. if (ownerId !== localParticipantId) {
  93. return {
  94. _isDisabled: isSharingStatus(sharedVideoStatus),
  95. _sharingVideo: false,
  96. visible
  97. };
  98. }
  99. return {
  100. _isDisabled: false,
  101. _sharingVideo: isSharingStatus(sharedVideoStatus),
  102. visible
  103. };
  104. }
  105. export default translate(connect(_mapStateToProps)(VideoShareButton));