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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 { translate } from '../../../base/i18n';
  7. import { Icon, IconAddPeople } from '../../../base/icons';
  8. import { getParticipantCountWithFake } from '../../../base/participants';
  9. import { connect } from '../../../base/redux';
  10. import { StyleType } from '../../../base/styles';
  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 the invite functions (dial out, invite, share...etc) are disabled.
  19. */
  20. _isInviteFunctionsDiabled: boolean,
  21. /**
  22. * True if it's a lonely meeting (participant count excluding fakes is 1).
  23. */
  24. _isLonelyMeeting: boolean,
  25. /**
  26. * Color schemed styles of the component.
  27. */
  28. _styles: StyleType,
  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. * Implements {@code PureComponent#render}.
  53. *
  54. * @inheritdoc
  55. */
  56. render() {
  57. const { _isInviteFunctionsDiabled, _isLonelyMeeting, _styles, t } = this.props;
  58. if (!_isLonelyMeeting) {
  59. return null;
  60. }
  61. return (
  62. <View style = { styles.lonelyMeetingContainer }>
  63. <Text
  64. style = { [
  65. styles.lonelyMessage,
  66. _styles.lonelyMessage
  67. ] }>
  68. { t('lonelyMeetingExperience.youAreAlone') }
  69. </Text>
  70. { !_isInviteFunctionsDiabled && (
  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. ) }
  90. </View>
  91. );
  92. }
  93. _onPress: () => void;
  94. /**
  95. * Callback for the onPress function of the button.
  96. *
  97. * @returns {void}
  98. */
  99. _onPress() {
  100. this.props.dispatch(doInvitePeople());
  101. }
  102. }
  103. /**
  104. * Maps parts of the Redux state to the props of this Component.
  105. *
  106. * @param {Object} state - The redux state.
  107. * @private
  108. * @returns {Props}
  109. */
  110. function _mapStateToProps(state): $Shape<Props> {
  111. const { disableInviteFunctions } = state['features/base/config'];
  112. const { conference } = state['features/base/conference'];
  113. const flag = getFeatureFlag(state, INVITE_ENABLED, true);
  114. return {
  115. _isInviteFunctionsDiabled: !flag || disableInviteFunctions,
  116. _isLonelyMeeting: conference && getParticipantCountWithFake(state) === 1,
  117. _styles: ColorSchemeRegistry.get(state, 'Conference')
  118. };
  119. }
  120. export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));