2020-03-20 17:30:46 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-07-07 12:29:18 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2020-03-20 17:30:46 +00:00
|
|
|
|
2022-09-27 07:10:28 +00:00
|
|
|
import { INVITE_ENABLED, getFeatureFlag } from '../../../base/flags';
|
2020-04-29 07:35:18 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { Icon, IconAddPeople } from '../../../base/icons';
|
2021-09-14 10:28:37 +00:00
|
|
|
import { getParticipantCountWithFake } from '../../../base/participants';
|
2020-03-20 17:30:46 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2022-07-27 08:40:34 +00:00
|
|
|
import Button from '../../../base/ui/components/native/Button';
|
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
2020-03-24 12:37:24 +00:00
|
|
|
import { doInvitePeople } from '../../../invite/actions.native';
|
2020-03-20 17:30:46 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Props type of the component.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* True if currently in a breakout room.
|
|
|
|
*/
|
2022-08-22 09:40:59 +00:00
|
|
|
_isInBreakoutRoom: boolean,
|
2021-09-14 15:31:30 +00:00
|
|
|
|
2020-04-09 13:26:19 +00:00
|
|
|
/**
|
|
|
|
* True if the invite functions (dial out, invite, share...etc) are disabled.
|
|
|
|
*/
|
|
|
|
_isInviteFunctionsDiabled: boolean,
|
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
/**
|
|
|
|
* True if it's a lonely meeting (participant count excluding fakes is 1).
|
|
|
|
*/
|
|
|
|
_isLonelyMeeting: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux Dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be used to translate i18n labels.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements the UI elements to be displayed in the lonely meeting experience.
|
|
|
|
*/
|
|
|
|
class LonelyMeetingExperience extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onPress = this._onPress.bind(this);
|
|
|
|
}
|
|
|
|
|
2022-07-07 12:29:18 +00:00
|
|
|
/**
|
|
|
|
* Renders the "add people" icon.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderAddPeopleIcon() {
|
|
|
|
return (
|
|
|
|
<Icon
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconAddPeople } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
/**
|
|
|
|
* Implements {@code PureComponent#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-09-14 15:31:30 +00:00
|
|
|
const {
|
|
|
|
_isInBreakoutRoom,
|
|
|
|
_isInviteFunctionsDiabled,
|
|
|
|
_isLonelyMeeting,
|
|
|
|
t
|
|
|
|
} = this.props;
|
2020-03-20 17:30:46 +00:00
|
|
|
|
|
|
|
if (!_isLonelyMeeting) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style = { styles.lonelyMeetingContainer }>
|
2022-06-20 21:09:13 +00:00
|
|
|
<Text style = { styles.lonelyMessage }>
|
2020-03-20 17:30:46 +00:00
|
|
|
{ t('lonelyMeetingExperience.youAreAlone') }
|
|
|
|
</Text>
|
2021-09-14 15:31:30 +00:00
|
|
|
{ !_isInviteFunctionsDiabled && !_isInBreakoutRoom && (
|
2022-07-07 12:29:18 +00:00
|
|
|
<Button
|
|
|
|
accessibilityLabel = 'lonelyMeetingExperience.button'
|
|
|
|
icon = { this._renderAddPeopleIcon }
|
2022-08-22 09:40:59 +00:00
|
|
|
labelKey = 'lonelyMeetingExperience.button'
|
|
|
|
onClick = { this._onPress }
|
2022-07-07 12:29:18 +00:00
|
|
|
style = { styles.lonelyButton }
|
|
|
|
type = { BUTTON_TYPES.PRIMARY } />
|
2020-04-09 13:26:19 +00:00
|
|
|
) }
|
2020-03-20 17:30:46 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback for the onPress function of the button.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onPress() {
|
2020-03-24 12:37:24 +00:00
|
|
|
this.props.dispatch(doInvitePeople());
|
2020-03-20 17:30:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps parts of the Redux state to the props of this Component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-06-20 21:09:13 +00:00
|
|
|
function _mapStateToProps(state) {
|
2020-04-09 13:26:19 +00:00
|
|
|
const { disableInviteFunctions } = state['features/base/config'];
|
2020-07-15 12:20:22 +00:00
|
|
|
const { conference } = state['features/base/conference'];
|
2020-04-29 07:35:18 +00:00
|
|
|
const flag = getFeatureFlag(state, INVITE_ENABLED, true);
|
2021-09-14 15:31:30 +00:00
|
|
|
const _isInBreakoutRoom = isInBreakoutRoom(state);
|
2020-04-09 13:26:19 +00:00
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
return {
|
2021-09-14 15:31:30 +00:00
|
|
|
_isInBreakoutRoom,
|
2020-04-29 07:35:18 +00:00
|
|
|
_isInviteFunctionsDiabled: !flag || disableInviteFunctions,
|
2022-06-20 21:09:13 +00:00
|
|
|
_isLonelyMeeting: conference && getParticipantCountWithFake(state) === 1
|
2020-03-20 17:30:46 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));
|