You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FlipLocalVideoButton.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* @flow */
  2. import React, { PureComponent } from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { connect } from '../../../base/redux';
  5. import { updateSettings } from '../../../base/settings';
  6. import VideoMenuButton from './VideoMenuButton';
  7. /**
  8. * The type of the React {@code Component} props of {@link FlipLocalVideoButton}.
  9. */
  10. type Props = {
  11. /**
  12. * The current local flip x status.
  13. */
  14. _localFlipX: boolean,
  15. /**
  16. * The redux dispatch function.
  17. */
  18. dispatch: Function,
  19. /**
  20. * Invoked to obtain translated strings.
  21. */
  22. t: Function
  23. };
  24. /**
  25. * Implements a React {@link Component} which displays a button for flipping the local viedo.
  26. *
  27. * @extends Component
  28. */
  29. class FlipLocalVideoButton extends PureComponent<Props> {
  30. /**
  31. * Initializes a new {@code FlipLocalVideoButton} instance.
  32. *
  33. * @param {Object} props - The read-only React Component props with which
  34. * the new instance is to be initialized.
  35. */
  36. constructor(props: Props) {
  37. super(props);
  38. // Bind event handlers so they are only bound once for every instance.
  39. this._onClick = this._onClick.bind(this);
  40. }
  41. /**
  42. * Implements React's {@link Component#render()}.
  43. *
  44. * @inheritdoc
  45. * @returns {null|ReactElement}
  46. */
  47. render() {
  48. const {
  49. t
  50. } = this.props;
  51. return (
  52. <VideoMenuButton
  53. buttonText = { t('videothumbnail.flip') }
  54. displayClass = 'fliplink'
  55. id = 'flipLocalVideoButton'
  56. onClick = { this._onClick } />
  57. );
  58. }
  59. _onClick: () => void;
  60. /**
  61. * Flips the local video.
  62. *
  63. * @private
  64. * @returns {void}
  65. */
  66. _onClick() {
  67. const { _localFlipX, dispatch } = this.props;
  68. dispatch(updateSettings({
  69. localFlipX: !_localFlipX
  70. }));
  71. }
  72. }
  73. /**
  74. * Maps (parts of) the Redux state to the associated {@code FlipLocalVideoButton}'s props.
  75. *
  76. * @param {Object} state - The Redux state.
  77. * @private
  78. * @returns {Props}
  79. */
  80. function _mapStateToProps(state) {
  81. const { localFlipX } = state['features/base/settings'];
  82. return {
  83. _localFlipX: Boolean(localFlipX)
  84. };
  85. }
  86. export default translate(connect(_mapStateToProps)(FlipLocalVideoButton));