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.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import { translate } from '../../base/i18n';
  4. import {
  5. IconShareAudio,
  6. IconStopAudioShare
  7. } from '../../base/icons';
  8. import { connect } from '../../base/redux';
  9. import {
  10. AbstractButton,
  11. type AbstractButtonProps
  12. } from '../../base/toolbox/components';
  13. import { setOverflowMenuVisible } from '../../toolbox/actions';
  14. import { startAudioScreenShareFlow } from '../actions';
  15. import { isAudioOnlySharing } from '../functions';
  16. type Props = AbstractButtonProps & {
  17. /**
  18. * The redux {@code dispatch} function.
  19. */
  20. dispatch: Dispatch<any>,
  21. /**
  22. * Whether or not the local participant is audio only screen sharing.
  23. */
  24. _isAudioOnlySharing: boolean
  25. }
  26. /**
  27. * Component that renders a toolbar button for toggling audio only screen share.
  28. */
  29. class ShareAudioButton extends AbstractButton<Props, *> {
  30. accessibilityLabel = 'toolbar.accessibilityLabel.shareaudio';
  31. icon = IconShareAudio;
  32. label = 'toolbar.shareaudio';
  33. tooltip = 'toolbar.shareaudio';
  34. toggledIcon = IconStopAudioShare;
  35. toggledLabel = 'toolbar.stopAudioSharing';
  36. /**
  37. * Handles clicking / pressing the button, and opens a new dialog.
  38. *
  39. * @private
  40. * @returns {void}
  41. */
  42. _handleClick() {
  43. const { dispatch, handleClick } = this.props;
  44. if (handleClick) {
  45. handleClick();
  46. return;
  47. }
  48. dispatch(startAudioScreenShareFlow());
  49. dispatch(setOverflowMenuVisible(false));
  50. }
  51. /**
  52. * Indicates whether this button is in toggled state or not.
  53. *
  54. * @override
  55. * @protected
  56. * @returns {boolean}
  57. */
  58. _isToggled() {
  59. return this.props._isAudioOnlySharing;
  60. }
  61. }
  62. /**
  63. * Maps part of the Redux state to the props of this component.
  64. *
  65. * @param {Object} state - The Redux state.
  66. * @private
  67. * @returns {Props}
  68. */
  69. function _mapStateToProps(state: Object): $Shape<Props> {
  70. return {
  71. _isAudioOnlySharing: isAudioOnlySharing(state)
  72. };
  73. }
  74. export default translate(connect(_mapStateToProps)(ShareAudioButton));