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

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