選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

NoiseSuppressionButton.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { connect } from 'react-redux';
  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 AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
  9. import { setOverflowMenuVisible } from '../../toolbox/actions';
  10. import { toggleNoiseSuppression } from '../actions';
  11. import { isNoiseSuppressionEnabled } from '../functions';
  12. interface IProps extends AbstractButtonProps {
  13. _isNoiseSuppressionEnabled?: boolean;
  14. }
  15. /**
  16. * Component that renders a toolbar button for toggling noise suppression.
  17. */
  18. class NoiseSuppressionButton extends AbstractButton<IProps> {
  19. accessibilityLabel = 'toolbar.accessibilityLabel.noiseSuppression';
  20. icon = IconNoiseSuppressionOn;
  21. label = 'toolbar.noiseSuppression';
  22. tooltip = 'toolbar.noiseSuppression';
  23. toggledIcon = IconNoiseSuppressionOff;
  24. toggledLabel = 'toolbar.disableNoiseSuppression';
  25. /**
  26. * Handles clicking / pressing the button.
  27. *
  28. * @private
  29. * @returns {void}
  30. */
  31. _handleClick() {
  32. const { dispatch } = this.props;
  33. dispatch(toggleNoiseSuppression());
  34. dispatch(setOverflowMenuVisible(false));
  35. }
  36. /**
  37. * Indicates whether this button is in toggled state or not.
  38. *
  39. * @override
  40. * @protected
  41. * @returns {boolean}
  42. */
  43. _isToggled() {
  44. return this.props._isNoiseSuppressionEnabled;
  45. }
  46. }
  47. /**
  48. * Maps part of the Redux state to the props of this component.
  49. *
  50. * @param {Object} state - The Redux state.
  51. * @private
  52. * @returns {IProps}
  53. */
  54. function _mapStateToProps(state: IReduxState) {
  55. return {
  56. _isNoiseSuppressionEnabled: isNoiseSuppressionEnabled(state)
  57. };
  58. }
  59. export default translate(connect(_mapStateToProps)(NoiseSuppressionButton));