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

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