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.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 } = this.props;
  44. dispatch(startAudioScreenShareFlow());
  45. dispatch(setOverflowMenuVisible(false));
  46. }
  47. /**
  48. * Indicates whether this button is in toggled state or not.
  49. *
  50. * @override
  51. * @protected
  52. * @returns {boolean}
  53. */
  54. _isToggled() {
  55. return this.props._isAudioOnlySharing;
  56. }
  57. }
  58. /**
  59. * Maps part of the Redux state to the props of this component.
  60. *
  61. * @param {Object} state - The Redux state.
  62. * @private
  63. * @returns {Props}
  64. */
  65. function _mapStateToProps(state: Object): $Shape<Props> {
  66. return {
  67. _isAudioOnlySharing: isAudioOnlySharing(state)
  68. };
  69. }
  70. export default translate(connect(_mapStateToProps)(ShareAudioButton));