Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

NoiseSuppressionButton.tsx 2.0KB

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