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.

NoiseSuppressionButton.tsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* eslint-disable lines-around-comment */
  2. import { IState } from '../../app/types';
  3. // @ts-ignore
  4. import { translate } from '../../base/i18n';
  5. // @ts-ignore
  6. import {
  7. IconShareAudio,
  8. IconStopAudioShare
  9. // @ts-ignore
  10. } from '../../base/icons';
  11. // @ts-ignore
  12. import { connect } from '../../base/redux';
  13. // @ts-ignore
  14. import {
  15. AbstractButton,
  16. type AbstractButtonProps
  17. // @ts-ignore
  18. } from '../../base/toolbox/components';
  19. // @ts-ignore
  20. import { setOverflowMenuVisible } from '../../toolbox/actions';
  21. import { toggleNoiseSuppression } from '../actions';
  22. import { isNoiseSuppressionEnabled } from '../functions';
  23. type Props = AbstractButtonProps & {
  24. /**
  25. * The redux {@code dispatch} function.
  26. */
  27. dispatch: Function;
  28. }
  29. /**
  30. * Component that renders a toolbar button for toggling noise suppression.
  31. */
  32. class NoiseSuppressionButton extends AbstractButton<Props, any, any> {
  33. accessibilityLabel = 'toolbar.accessibilityLabel.noiseSuppression';
  34. icon = IconShareAudio;
  35. label = 'toolbar.noiseSuppression';
  36. tooltip = 'toolbar.noiseSuppression';
  37. toggledIcon = IconStopAudioShare;
  38. toggledLabel = 'toolbar.disableNoiseSuppression';
  39. private props: Props;
  40. /**
  41. * Handles clicking / pressing the button.
  42. *
  43. * @private
  44. * @returns {void}
  45. */
  46. _handleClick() {
  47. const { dispatch } = this.props;
  48. dispatch(toggleNoiseSuppression());
  49. dispatch(setOverflowMenuVisible(false));
  50. }
  51. /**
  52. * Indicates whether this button is in toggled state or not.
  53. *
  54. * @override
  55. * @protected
  56. * @returns {boolean}
  57. */
  58. _isToggled() {
  59. return this.props._isNoiseSuppressionEnabled;
  60. }
  61. }
  62. /**
  63. * Maps part of the Redux state to the props of this component.
  64. *
  65. * @param {Object} state - The Redux state.
  66. * @private
  67. * @returns {Props}
  68. */
  69. function _mapStateToProps(state: IState): Object {
  70. return {
  71. _isNoiseSuppressionEnabled: isNoiseSuppressionEnabled(state)
  72. };
  73. }
  74. export default translate(connect(_mapStateToProps)(NoiseSuppressionButton));