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.js 3.8KB

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