2021-01-21 14:46:47 -06:00
|
|
|
import React, { PureComponent } from 'react';
|
2023-03-30 11:27:53 +03:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-01-21 14:46:47 -06:00
|
|
|
|
2023-03-30 11:27:53 +03:00
|
|
|
import { IReduxState, IStore } from '../../../app/types';
|
|
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
|
import { updateSettings } from '../../../base/settings/actions';
|
2022-10-06 13:09:40 +03:00
|
|
|
import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
|
2021-01-21 14:46:47 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The type of the React {@code Component} props of {@link FlipLocalVideoButton}.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
interface IProps extends WithTranslation {
|
2021-01-21 14:46:47 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The current local flip x status.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
_localFlipX: boolean;
|
2021-01-21 14:46:47 -06:00
|
|
|
|
2021-12-15 15:18:41 +02:00
|
|
|
/**
|
|
|
|
|
* Button text class name.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
className: string;
|
2021-12-15 15:18:41 +02:00
|
|
|
|
2021-01-21 14:46:47 -06:00
|
|
|
/**
|
|
|
|
|
* The redux dispatch function.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
dispatch: IStore['dispatch'];
|
2021-01-21 14:46:47 -06:00
|
|
|
|
2021-11-01 11:39:19 +02:00
|
|
|
/**
|
|
|
|
|
* Click handler executed aside from the main action.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
onClick?: Function;
|
|
|
|
|
}
|
2021-01-21 14:46:47 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements a React {@link Component} which displays a button for flipping the local viedo.
|
|
|
|
|
*
|
2021-11-04 22:10:43 +01:00
|
|
|
* @augments Component
|
2021-01-21 14:46:47 -06:00
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
class FlipLocalVideoButton extends PureComponent<IProps> {
|
2021-01-21 14:46:47 -06:00
|
|
|
/**
|
|
|
|
|
* Initializes a new {@code FlipLocalVideoButton} instance.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
constructor(props: IProps) {
|
2021-01-21 14:46:47 -06:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
|
*
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
* @returns {null|ReactElement}
|
|
|
|
|
*/
|
|
|
|
|
render() {
|
|
|
|
|
const {
|
2021-12-15 15:18:41 +02:00
|
|
|
className,
|
2021-01-21 14:46:47 -06:00
|
|
|
t
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
2021-12-15 15:18:41 +02:00
|
|
|
<ContextMenuItem
|
|
|
|
|
accessibilityLabel = { t('videothumbnail.flip') }
|
|
|
|
|
className = 'fliplink'
|
2021-01-21 14:46:47 -06:00
|
|
|
id = 'flipLocalVideoButton'
|
2021-12-15 15:18:41 +02:00
|
|
|
onClick = { this._onClick }
|
|
|
|
|
text = { t('videothumbnail.flip') }
|
|
|
|
|
textClassName = { className } />
|
2021-01-21 14:46:47 -06:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Flips the local video.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_onClick() {
|
2021-11-01 11:39:19 +02:00
|
|
|
const { _localFlipX, dispatch, onClick } = this.props;
|
2021-01-21 14:46:47 -06:00
|
|
|
|
2023-03-30 11:27:53 +03:00
|
|
|
onClick?.();
|
2021-01-21 14:46:47 -06:00
|
|
|
dispatch(updateSettings({
|
|
|
|
|
localFlipX: !_localFlipX
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code FlipLocalVideoButton}'s props.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
|
* @private
|
2023-03-30 11:27:53 +03:00
|
|
|
* @returns {IProps}
|
2021-01-21 14:46:47 -06:00
|
|
|
*/
|
2023-03-30 11:27:53 +03:00
|
|
|
function _mapStateToProps(state: IReduxState) {
|
2021-01-21 14:46:47 -06:00
|
|
|
const { localFlipX } = state['features/base/settings'];
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
_localFlipX: Boolean(localFlipX)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(FlipLocalVideoButton));
|