2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
2023-03-30 11:27:53 +03:00
|
|
|
import { IReduxState } from '../../app/types';
|
2023-06-29 14:59:12 +03:00
|
|
|
import { getMultipleVideoSendingSupportFeatureFlag } from '../../base/config/functions.any';
|
2023-03-30 11:27:53 +03:00
|
|
|
import { translate } from '../../base/i18n/functions';
|
|
|
|
|
import { IconImage } from '../../base/icons/svg';
|
|
|
|
|
import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
|
2023-06-29 14:59:12 +03:00
|
|
|
import { isScreenVideoShared } from '../../screen-share/functions';
|
2023-03-08 13:15:07 +02:00
|
|
|
import { openSettingsDialog } from '../../settings/actions';
|
|
|
|
|
import { SETTINGS_TABS } from '../../settings/constants';
|
2021-08-20 11:53:11 +03:00
|
|
|
import { checkBlurSupport } from '../functions';
|
2021-02-18 17:52:47 +02:00
|
|
|
|
2019-06-28 20:18:47 +03:00
|
|
|
/**
|
2021-02-18 17:52:47 +02:00
|
|
|
* The type of the React {@code Component} props of {@link VideoBackgroundButton}.
|
2019-06-28 20:18:47 +03:00
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
interface IProps extends AbstractButtonProps {
|
2019-06-28 20:18:47 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* True if the video background is blurred or false if it is not.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
_isBackgroundEnabled: boolean;
|
|
|
|
|
}
|
2019-06-28 20:18:47 +03:00
|
|
|
|
|
|
|
|
/**
|
2021-02-18 17:52:47 +02:00
|
|
|
* An abstract implementation of a button that toggles the video background dialog.
|
2019-06-28 20:18:47 +03:00
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
class VideoBackgroundButton extends AbstractButton<IProps> {
|
2021-02-18 17:52:47 +02:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.selectBackground';
|
2022-11-08 12:24:32 +02:00
|
|
|
icon = IconImage;
|
2021-02-18 17:52:47 +02:00
|
|
|
label = 'toolbar.selectBackground';
|
|
|
|
|
tooltip = 'toolbar.selectBackground';
|
2019-06-28 20:18:47 +03:00
|
|
|
|
|
|
|
|
/**
|
2021-02-18 17:52:47 +02:00
|
|
|
* Handles clicking / pressing the button, and toggles the virtual background dialog
|
2019-06-28 20:18:47 +03:00
|
|
|
* state accordingly.
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_handleClick() {
|
2022-01-04 13:21:00 +02:00
|
|
|
const { dispatch } = this.props;
|
2019-06-28 20:18:47 +03:00
|
|
|
|
2023-03-08 13:15:07 +02:00
|
|
|
dispatch(openSettingsDialog(SETTINGS_TABS.VIRTUAL_BACKGROUND));
|
2019-06-28 20:18:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-18 17:52:47 +02:00
|
|
|
* Returns {@code boolean} value indicating if the background effect is
|
2019-06-28 20:18:47 +03:00
|
|
|
* enabled or not.
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
_isToggled() {
|
2021-02-18 17:52:47 +02:00
|
|
|
return this.props._isBackgroundEnabled;
|
2019-06-28 20:18:47 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
2021-02-18 17:52:47 +02:00
|
|
|
* {@code VideoBackgroundButton} component.
|
2019-06-28 20:18:47 +03:00
|
|
|
*
|
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {{
|
2021-02-18 17:52:47 +02:00
|
|
|
* _isBackgroundEnabled: boolean
|
2019-06-28 20:18:47 +03:00
|
|
|
* }}
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
function _mapStateToProps(state: IReduxState) {
|
2021-02-26 17:03:51 +02:00
|
|
|
|
2019-06-28 20:18:47 +03:00
|
|
|
return {
|
2021-08-20 11:53:11 +03:00
|
|
|
_isBackgroundEnabled: Boolean(state['features/virtual-background'].backgroundEffectEnabled),
|
2023-06-29 14:59:12 +03:00
|
|
|
visible: checkBlurSupport() && getMultipleVideoSendingSupportFeatureFlag(state) && !isScreenVideoShared(state)
|
2019-06-28 20:18:47 +03:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-18 17:52:47 +02:00
|
|
|
export default translate(connect(_mapStateToProps)(VideoBackgroundButton));
|