Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

NoiseSuppressionButton.tsx 2.0KB

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