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

PrivateMessageButton.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // @flow
  2. import { CHAT_ENABLED, getFeatureFlag } from '../../../base/flags';
  3. import { translate } from '../../../base/i18n';
  4. import { IconMessage, IconReply } from '../../../base/icons';
  5. import { getParticipantById } from '../../../base/participants';
  6. import { connect } from '../../../base/redux';
  7. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  8. import { navigate } from '../../../conference/components/native/ConferenceNavigationContainerRef';
  9. import { screen } from '../../../conference/components/native/routes';
  10. export type Props = AbstractButtonProps & {
  11. /**
  12. * The ID of the participant that the message is to be sent.
  13. */
  14. participantID: string,
  15. /**
  16. * True if the button is rendered as a reply button.
  17. */
  18. reply: boolean,
  19. /**
  20. * Function to be used to translate i18n labels.
  21. */
  22. t: Function,
  23. /**
  24. * True if the polls feature is disabled.
  25. */
  26. _isPollsDisabled: boolean,
  27. /**
  28. * The participant object retrieved from Redux.
  29. */
  30. _participant: Object,
  31. };
  32. /**
  33. * Class to render a button that initiates the sending of a private message through chet.
  34. */
  35. class PrivateMessageButton extends AbstractButton<Props, any> {
  36. accessibilityLabel = 'toolbar.accessibilityLabel.privateMessage';
  37. icon = IconMessage;
  38. label = 'toolbar.privateMessage';
  39. toggledIcon = IconReply;
  40. /**
  41. * Handles clicking / pressing the button, and kicks the participant.
  42. *
  43. * @private
  44. * @returns {void}
  45. */
  46. _handleClick() {
  47. this.props._isPollsDisabled
  48. ? navigate(screen.conference.chat, {
  49. privateMessageRecipient: this.props._participant
  50. })
  51. : navigate(screen.conference.chatandpolls.main, {
  52. screen: screen.conference.chatandpolls.tab.chat,
  53. params: {
  54. privateMessageRecipient: this.props._participant
  55. }
  56. });
  57. }
  58. /**
  59. * Helper function to be implemented by subclasses, which must return a
  60. * {@code boolean} value indicating if this button is toggled or not.
  61. *
  62. * @protected
  63. * @returns {boolean}
  64. */
  65. _isToggled() {
  66. return this.props.reply;
  67. }
  68. }
  69. /**
  70. * Maps part of the Redux store to the props of this component.
  71. *
  72. * @param {Object} state - The Redux state.
  73. * @param {Props} ownProps - The own props of the component.
  74. * @returns {Props}
  75. */
  76. export function _mapStateToProps(state: Object, ownProps: Props): $Shape<Props> {
  77. const enabled = getFeatureFlag(state, CHAT_ENABLED, true);
  78. const { disablePolls } = state['features/base/config'];
  79. const { visible = enabled } = ownProps;
  80. return {
  81. _isPollsDisabled: disablePolls,
  82. _participant: getParticipantById(state, ownProps.participantID),
  83. visible
  84. };
  85. }
  86. export default translate(connect(_mapStateToProps)(PrivateMessageButton));