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.

ShareAudioButton.ts 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconVolumeOff, IconVolumeUp } from '../../../base/icons/svg';
  5. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  6. import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
  7. import { startAudioScreenShareFlow } from '../../actions.web';
  8. import { isAudioOnlySharing } from '../../functions';
  9. interface IProps extends AbstractButtonProps {
  10. /**
  11. * Whether or not the local participant is audio only screen sharing.
  12. */
  13. _isAudioOnlySharing: boolean;
  14. }
  15. /**
  16. * Component that renders a toolbar button for toggling audio only screen share.
  17. */
  18. class ShareAudioButton extends AbstractButton<IProps> {
  19. accessibilityLabel = 'toolbar.accessibilityLabel.shareaudio';
  20. icon = IconVolumeUp;
  21. label = 'toolbar.shareaudio';
  22. tooltip = 'toolbar.shareaudio';
  23. toggledIcon = IconVolumeOff;
  24. toggledLabel = 'toolbar.stopAudioSharing';
  25. /**
  26. * Handles clicking / pressing the button, and opens a new dialog.
  27. *
  28. * @private
  29. * @returns {void}
  30. */
  31. _handleClick() {
  32. const { dispatch } = this.props;
  33. dispatch(startAudioScreenShareFlow());
  34. dispatch(setOverflowMenuVisible(false));
  35. }
  36. /**
  37. * Indicates whether this button is in toggled state or not.
  38. *
  39. * @override
  40. * @protected
  41. * @returns {boolean}
  42. */
  43. _isToggled() {
  44. return this.props._isAudioOnlySharing;
  45. }
  46. }
  47. /**
  48. * Maps part of the Redux state to the props of this component.
  49. *
  50. * @param {Object} state - The Redux state.
  51. * @private
  52. * @returns {IProps}
  53. */
  54. function _mapStateToProps(state: IReduxState) {
  55. return {
  56. _isAudioOnlySharing: Boolean(isAudioOnlySharing(state))
  57. };
  58. }
  59. export default translate(connect(_mapStateToProps)(ShareAudioButton));