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

LonelyMeetingExperience.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import React, { PureComponent } from 'react';
  2. import { Text, View } from 'react-native';
  3. import { INVITE_ENABLED, getFeatureFlag } from '../../../base/flags';
  4. import { translate } from '../../../base/i18n';
  5. import { Icon, IconAddPeople } from '../../../base/icons';
  6. import { getParticipantCountWithFake } from '../../../base/participants';
  7. import { connect } from '../../../base/redux';
  8. import Button from '../../../base/ui/components/native/Button';
  9. import { BUTTON_TYPES } from '../../../base/ui/constants';
  10. import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
  11. import { doInvitePeople } from '../../../invite/actions.native';
  12. import styles from './styles';
  13. /**
  14. * Props type of the component.
  15. */
  16. type Props = {
  17. /**
  18. * True if currently in a breakout room.
  19. */
  20. _isInBreakoutRoom: boolean,
  21. /**
  22. * True if the invite functions (dial out, invite, share...etc) are disabled.
  23. */
  24. _isInviteFunctionsDiabled: boolean,
  25. /**
  26. * True if it's a lonely meeting (participant count excluding fakes is 1).
  27. */
  28. _isLonelyMeeting: boolean,
  29. /**
  30. * The Redux Dispatch function.
  31. */
  32. dispatch: Function,
  33. /**
  34. * Function to be used to translate i18n labels.
  35. */
  36. t: Function
  37. };
  38. /**
  39. * Implements the UI elements to be displayed in the lonely meeting experience.
  40. */
  41. class LonelyMeetingExperience extends PureComponent<Props> {
  42. /**
  43. * Instantiates a new component.
  44. *
  45. * @inheritdoc
  46. */
  47. constructor(props: Props) {
  48. super(props);
  49. this._onPress = this._onPress.bind(this);
  50. }
  51. /**
  52. * Renders the "add people" icon.
  53. *
  54. * @returns {ReactElement}
  55. */
  56. _renderAddPeopleIcon() {
  57. return (
  58. <Icon
  59. size = { 20 }
  60. src = { IconAddPeople } />
  61. );
  62. }
  63. /**
  64. * Implements {@code PureComponent#render}.
  65. *
  66. * @inheritdoc
  67. */
  68. render() {
  69. const {
  70. _isInBreakoutRoom,
  71. _isInviteFunctionsDiabled,
  72. _isLonelyMeeting,
  73. t
  74. } = this.props;
  75. if (!_isLonelyMeeting) {
  76. return null;
  77. }
  78. return (
  79. <View style = { styles.lonelyMeetingContainer }>
  80. <Text style = { styles.lonelyMessage }>
  81. { t('lonelyMeetingExperience.youAreAlone') }
  82. </Text>
  83. { !_isInviteFunctionsDiabled && !_isInBreakoutRoom && (
  84. <Button
  85. accessibilityLabel = 'lonelyMeetingExperience.button'
  86. icon = { this._renderAddPeopleIcon }
  87. labelKey = 'lonelyMeetingExperience.button'
  88. onClick = { this._onPress }
  89. style = { styles.lonelyButton }
  90. type = { BUTTON_TYPES.PRIMARY } />
  91. ) }
  92. </View>
  93. );
  94. }
  95. /**
  96. * Callback for the onPress function of the button.
  97. *
  98. * @returns {void}
  99. */
  100. _onPress() {
  101. this.props.dispatch(doInvitePeople());
  102. }
  103. }
  104. /**
  105. * Maps parts of the Redux state to the props of this Component.
  106. *
  107. * @param {Object} state - The redux state.
  108. * @private
  109. * @returns {Props}
  110. */
  111. function _mapStateToProps(state) {
  112. const { disableInviteFunctions } = state['features/base/config'];
  113. const { conference } = state['features/base/conference'];
  114. const flag = getFeatureFlag(state, INVITE_ENABLED, true);
  115. const _isInBreakoutRoom = isInBreakoutRoom(state);
  116. return {
  117. _isInBreakoutRoom,
  118. _isInviteFunctionsDiabled: !flag || disableInviteFunctions,
  119. _isLonelyMeeting: conference && getParticipantCountWithFake(state) === 1
  120. };
  121. }
  122. export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));