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.

AudioOnlyButton.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // @flow
  2. import { toggleAudioOnly } from '../../../base/audio-only';
  3. import { translate } from '../../../base/i18n';
  4. import { IconAudioOnly, IconAudioOnlyOff } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. /**
  8. * The type of the React {@code Component} props of {@link AudioOnlyButton}.
  9. */
  10. type Props = AbstractButtonProps & {
  11. /**
  12. * Whether the current conference is in audio only mode or not.
  13. */
  14. _audioOnly: boolean,
  15. /**
  16. * The redux {@code dispatch} function.
  17. */
  18. dispatch: Function
  19. };
  20. /**
  21. * An implementation of a button for toggling the audio-only mode.
  22. */
  23. class AudioOnlyButton extends AbstractButton<Props, *> {
  24. accessibilityLabel = 'toolbar.accessibilityLabel.audioOnly';
  25. icon = IconAudioOnly;
  26. label = 'toolbar.audioOnlyOn';
  27. toggledIcon = IconAudioOnlyOff;
  28. toggledLabel = 'toolbar.audioOnlyOff';
  29. /**
  30. * Handles clicking / pressing the button.
  31. *
  32. * @override
  33. * @protected
  34. * @returns {void}
  35. */
  36. _handleClick() {
  37. this.props.dispatch(toggleAudioOnly());
  38. }
  39. /**
  40. * Indicates whether this button is in toggled state or not.
  41. *
  42. * @override
  43. * @protected
  44. * @returns {boolean}
  45. */
  46. _isToggled() {
  47. return this.props._audioOnly;
  48. }
  49. }
  50. /**
  51. * Maps (parts of) the redux state to the associated props for the
  52. * {@code AudioOnlyButton} component.
  53. *
  54. * @param {Object} state - The Redux state.
  55. * @private
  56. * @returns {{
  57. * _audioOnly: boolean
  58. * }}
  59. */
  60. function _mapStateToProps(state): Object {
  61. const { enabled: audioOnly } = state['features/base/audio-only'];
  62. return {
  63. _audioOnly: Boolean(audioOnly)
  64. };
  65. }
  66. export default translate(connect(_mapStateToProps)(AudioOnlyButton));