2022-07-20 12:31:17 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
|
|
|
import { IState } from '../../app/types';
|
2022-08-08 09:36:06 +00:00
|
|
|
import { translate } from '../../base/i18n/functions';
|
2022-07-20 12:31:17 +00:00
|
|
|
import {
|
2022-08-01 08:58:37 +00:00
|
|
|
IconNoiseSuppressionOn,
|
|
|
|
IconNoiseSuppressionOff
|
2022-09-06 17:32:20 +00:00
|
|
|
} from '../../base/icons/svg';
|
2022-07-27 09:56:07 +00:00
|
|
|
import { connect } from '../../base/redux/functions';
|
2022-07-20 12:31:17 +00:00
|
|
|
import {
|
|
|
|
AbstractButton,
|
|
|
|
type AbstractButtonProps
|
|
|
|
// @ts-ignore
|
|
|
|
} from '../../base/toolbox/components';
|
|
|
|
// @ts-ignore
|
|
|
|
import { setOverflowMenuVisible } from '../../toolbox/actions';
|
|
|
|
import { toggleNoiseSuppression } from '../actions';
|
|
|
|
import { isNoiseSuppressionEnabled } from '../functions';
|
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function;
|
|
|
|
|
2022-09-08 09:52:36 +00:00
|
|
|
};
|
2022-07-20 12:31:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders a toolbar button for toggling noise suppression.
|
|
|
|
*/
|
|
|
|
class NoiseSuppressionButton extends AbstractButton<Props, any, any> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.noiseSuppression';
|
2022-08-01 08:58:37 +00:00
|
|
|
icon = IconNoiseSuppressionOn;
|
2022-07-20 12:31:17 +00:00
|
|
|
label = 'toolbar.noiseSuppression';
|
|
|
|
tooltip = 'toolbar.noiseSuppression';
|
2022-08-01 08:58:37 +00:00
|
|
|
toggledIcon = IconNoiseSuppressionOff;
|
2022-07-20 12:31:17 +00:00
|
|
|
toggledLabel = 'toolbar.disableNoiseSuppression';
|
|
|
|
|
|
|
|
private props: Props;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
|
|
|
dispatch(toggleNoiseSuppression());
|
|
|
|
dispatch(setOverflowMenuVisible(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._isNoiseSuppressionEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state: IState): Object {
|
|
|
|
return {
|
|
|
|
_isNoiseSuppressionEnabled: isNoiseSuppressionEnabled(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-27 09:56:07 +00:00
|
|
|
// @ts-ignore
|
2022-07-20 12:31:17 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(NoiseSuppressionButton));
|