Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

FlipLocalVideoButton.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. * Click handler executed aside from the main action.
  21. */
  22. onClick?: Function,
  23. /**
  24. * Invoked to obtain translated strings.
  25. */
  26. t: Function
  27. };
  28. /**
  29. * Implements a React {@link Component} which displays a button for flipping the local viedo.
  30. *
  31. * @augments Component
  32. */
  33. class FlipLocalVideoButton extends PureComponent<Props> {
  34. /**
  35. * Initializes a new {@code FlipLocalVideoButton} instance.
  36. *
  37. * @param {Object} props - The read-only React Component props with which
  38. * the new instance is to be initialized.
  39. */
  40. constructor(props: Props) {
  41. super(props);
  42. // Bind event handlers so they are only bound once for every instance.
  43. this._onClick = this._onClick.bind(this);
  44. }
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {null|ReactElement}
  50. */
  51. render() {
  52. const {
  53. t
  54. } = this.props;
  55. return (
  56. <VideoMenuButton
  57. buttonText = { t('videothumbnail.flip') }
  58. displayClass = 'fliplink'
  59. id = 'flipLocalVideoButton'
  60. onClick = { this._onClick } />
  61. );
  62. }
  63. _onClick: () => void;
  64. /**
  65. * Flips the local video.
  66. *
  67. * @private
  68. * @returns {void}
  69. */
  70. _onClick() {
  71. const { _localFlipX, dispatch, onClick } = this.props;
  72. onClick && onClick();
  73. dispatch(updateSettings({
  74. localFlipX: !_localFlipX
  75. }));
  76. }
  77. }
  78. /**
  79. * Maps (parts of) the Redux state to the associated {@code FlipLocalVideoButton}'s props.
  80. *
  81. * @param {Object} state - The Redux state.
  82. * @private
  83. * @returns {Props}
  84. */
  85. function _mapStateToProps(state) {
  86. const { localFlipX } = state['features/base/settings'];
  87. return {
  88. _localFlipX: Boolean(localFlipX)
  89. };
  90. }
  91. export default translate(connect(_mapStateToProps)(FlipLocalVideoButton));