2021-01-21 20:46:47 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { updateSettings } from '../../../base/settings';
|
2022-10-06 10:09:40 +00:00
|
|
|
import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
|
2021-01-21 20:46:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link FlipLocalVideoButton}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current local flip x status.
|
|
|
|
*/
|
|
|
|
_localFlipX: boolean,
|
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
/**
|
|
|
|
* Button text class name.
|
|
|
|
*/
|
|
|
|
className: string,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* The redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
/**
|
|
|
|
* Click handler executed aside from the main action.
|
|
|
|
*/
|
|
|
|
onClick?: Function,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which displays a button for flipping the local viedo.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
class FlipLocalVideoButton extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Initializes a new {@code FlipLocalVideoButton} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
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 13:18:41 +00:00
|
|
|
className,
|
2021-01-21 20:46:47 +00:00
|
|
|
t
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
2021-12-15 13:18:41 +00:00
|
|
|
<ContextMenuItem
|
|
|
|
accessibilityLabel = { t('videothumbnail.flip') }
|
|
|
|
className = 'fliplink'
|
2021-01-21 20:46:47 +00:00
|
|
|
id = 'flipLocalVideoButton'
|
2021-12-15 13:18:41 +00:00
|
|
|
onClick = { this._onClick }
|
|
|
|
text = { t('videothumbnail.flip') }
|
|
|
|
textClassName = { className } />
|
2021-01-21 20:46:47 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flips the local video.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
2021-11-01 09:39:19 +00:00
|
|
|
const { _localFlipX, dispatch, onClick } = this.props;
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
onClick && onClick();
|
2021-01-21 20:46:47 +00: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
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
const { localFlipX } = state['features/base/settings'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
_localFlipX: Boolean(localFlipX)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(FlipLocalVideoButton));
|