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.

ShareDesktopButton.ts 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconScreenshare, IconStopScreenshare } from '../../../base/icons/svg';
  5. import JitsiMeetJS from '../../../base/lib-jitsi-meet/_';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import { isScreenVideoShared } from '../../../screen-share/functions';
  8. import { isDesktopShareButtonDisabled } from '../../functions';
  9. interface IProps extends AbstractButtonProps {
  10. /**
  11. * Whether or not screensharing is initialized.
  12. */
  13. _desktopSharingEnabled: boolean;
  14. /**
  15. * Whether or not the local participant is screensharing.
  16. */
  17. _screensharing: boolean;
  18. }
  19. /**
  20. * Implementation of a button for sharing desktop / windows.
  21. */
  22. class ShareDesktopButton extends AbstractButton<IProps> {
  23. accessibilityLabel = 'toolbar.accessibilityLabel.shareYourScreen';
  24. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.stopScreenSharing';
  25. label = 'toolbar.startScreenSharing';
  26. icon = IconScreenshare;
  27. toggledIcon = IconStopScreenshare;
  28. toggledLabel = 'toolbar.stopScreenSharing';
  29. /**
  30. * Retrieves tooltip dynamically.
  31. *
  32. * @returns {string}
  33. */
  34. _getTooltip() {
  35. const { _desktopSharingEnabled, _screensharing } = this.props;
  36. if (_desktopSharingEnabled) {
  37. if (_screensharing) {
  38. return 'toolbar.stopScreenSharing';
  39. }
  40. return 'toolbar.startScreenSharing';
  41. }
  42. return 'dialog.shareYourScreenDisabled';
  43. }
  44. /**
  45. * Indicates whether this button is in toggled state or not.
  46. *
  47. * @override
  48. * @protected
  49. * @returns {boolean}
  50. */
  51. _isToggled() {
  52. return this.props._screensharing;
  53. }
  54. /**
  55. * Indicates whether this button is in disabled state or not.
  56. *
  57. * @override
  58. * @protected
  59. * @returns {boolean}
  60. */
  61. _isDisabled() {
  62. return !this.props._desktopSharingEnabled;
  63. }
  64. }
  65. /**
  66. * Function that maps parts of Redux state tree into component props.
  67. *
  68. * @param {Object} state - Redux state.
  69. * @returns {Object}
  70. */
  71. const mapStateToProps = (state: IReduxState) => {
  72. // Disable the screenshare button if the video sender limit is reached and there is no video or media share in
  73. // progress.
  74. const desktopSharingEnabled
  75. = JitsiMeetJS.isDesktopSharingEnabled() && !isDesktopShareButtonDisabled(state);
  76. return {
  77. _desktopSharingEnabled: desktopSharingEnabled,
  78. _screensharing: isScreenVideoShared(state)
  79. };
  80. };
  81. export default translate(connect(mapStateToProps)(ShareDesktopButton));