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

SharedVideoButton.js 2.6KB

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