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 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @flow
  2. import { toggleAudioOnly } from '../../../base/audio-only';
  3. import { AUDIO_ONLY_BUTTON_ENABLED, getFeatureFlag } from '../../../base/flags';
  4. import { translate } from '../../../base/i18n';
  5. import { IconAudioOnly, IconAudioOnlyOff } from '../../../base/icons';
  6. import { connect } from '../../../base/redux';
  7. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  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. * @param {Object} ownProps - The properties explicitly passed to the component instance.
  57. * @private
  58. * @returns {{
  59. * _audioOnly: boolean
  60. * }}
  61. */
  62. function _mapStateToProps(state, ownProps): Object {
  63. const { enabled: audioOnly } = state['features/base/audio-only'];
  64. const enabledInFeatureFlags = getFeatureFlag(state, AUDIO_ONLY_BUTTON_ENABLED, true);
  65. const { visible = enabledInFeatureFlags } = ownProps;
  66. return {
  67. _audioOnly: Boolean(audioOnly),
  68. visible
  69. };
  70. }
  71. export default translate(connect(_mapStateToProps)(AudioOnlyButton));