Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

RaiseHandButton.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { type Dispatch } from 'redux';
  4. import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  5. import { sendAnalytics } from '../../../analytics/functions';
  6. import { RAISE_HAND_ENABLED } from '../../../base/flags/constants';
  7. import { getFeatureFlag } from '../../../base/flags/functions';
  8. import { translate } from '../../../base/i18n/functions';
  9. import { IconRaiseHand } from '../../../base/icons/svg';
  10. import { raiseHand } from '../../../base/participants/actions';
  11. import {
  12. getLocalParticipant,
  13. hasRaisedHand
  14. } from '../../../base/participants/functions';
  15. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  16. /**
  17. * The type of the React {@code Component} props of {@link RaiseHandButton}.
  18. */
  19. type Props = AbstractButtonProps & {
  20. /**
  21. * The local participant.
  22. */
  23. _localParticipant: Object,
  24. /**
  25. * Whether the participant raused their hand or not.
  26. */
  27. _raisedHand: boolean,
  28. /**
  29. * The redux {@code dispatch} function.
  30. */
  31. dispatch: Dispatch<any>
  32. };
  33. /**
  34. * An implementation of a button to raise or lower hand.
  35. */
  36. class RaiseHandButton extends AbstractButton<Props, *> {
  37. accessibilityLabel = 'toolbar.accessibilityLabel.raiseHand';
  38. icon = IconRaiseHand;
  39. label = 'toolbar.raiseYourHand';
  40. toggledLabel = 'toolbar.lowerYourHand';
  41. /**
  42. * Handles clicking / pressing the button.
  43. *
  44. * @override
  45. * @protected
  46. * @returns {void}
  47. */
  48. _handleClick() {
  49. this._toggleRaisedHand();
  50. }
  51. /**
  52. * Indicates whether this button is in toggled state or not.
  53. *
  54. * @override
  55. * @protected
  56. * @returns {boolean}
  57. */
  58. _isToggled() {
  59. return this.props._raisedHand;
  60. }
  61. /**
  62. * Toggles the rased hand status of the local participant.
  63. *
  64. * @returns {void}
  65. */
  66. _toggleRaisedHand() {
  67. const enable = !this.props._raisedHand;
  68. sendAnalytics(createToolbarEvent('raise.hand', { enable }));
  69. this.props.dispatch(raiseHand(enable));
  70. }
  71. }
  72. /**
  73. * Maps part of the Redux state to the props of this component.
  74. *
  75. * @param {Object} state - The Redux state.
  76. * @param {Object} ownProps - The properties explicitly passed to the component instance.
  77. * @private
  78. * @returns {Props}
  79. */
  80. function _mapStateToProps(state, ownProps): Object {
  81. const _localParticipant = getLocalParticipant(state);
  82. const enabled = getFeatureFlag(state, RAISE_HAND_ENABLED, true);
  83. const { visible = enabled } = ownProps;
  84. return {
  85. _localParticipant,
  86. _raisedHand: hasRaisedHand(_localParticipant),
  87. visible
  88. };
  89. }
  90. export default translate(connect(_mapStateToProps)(RaiseHandButton));