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

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