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.

LonelyMeetingExperience.tsx 4.5KB

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