2023-01-12 10:13:18 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2023-01-12 10:13:18 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2022-07-07 12:29:18 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2020-03-20 17:30:46 +00:00
|
|
|
|
2023-01-12 10:13:18 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
|
|
|
// @ts-ignore
|
|
|
|
import { INVITE_ENABLED, getFeatureFlag } from '../../../base/flags/';
|
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
// @ts-ignore
|
2022-11-08 10:24:32 +00:00
|
|
|
import { Icon, IconAddUser } from '../../../base/icons';
|
2023-01-12 10:13:18 +00:00
|
|
|
import { getParticipantCountWithFake } from '../../../base/participants/functions';
|
|
|
|
import { connect } from '../../../base/redux/functions';
|
2022-07-27 08:40:34 +00:00
|
|
|
import Button from '../../../base/ui/components/native/Button';
|
2022-11-09 12:45:55 +00:00
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
|
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';
|
2023-01-12 10:13:18 +00:00
|
|
|
import { toggleShareDialog } from '../../../share-room/actions';
|
2023-01-12 13:47:44 +00:00
|
|
|
import { getInviteOthersControl } from '../../../share-room/functions';
|
2020-03-20 17:30:46 +00:00
|
|
|
|
2023-01-12 10:13:18 +00:00
|
|
|
// @ts-ignore
|
2020-03-20 17:30:46 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2023-01-12 10:13:18 +00:00
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
/**
|
|
|
|
* Props type of the component.
|
|
|
|
*/
|
2023-01-12 10:13:18 +00:00
|
|
|
type Props = WithTranslation & {
|
2020-03-20 17:30:46 +00:00
|
|
|
|
2023-01-12 13:47:44 +00:00
|
|
|
/**
|
|
|
|
* Control for invite other button.
|
|
|
|
*/
|
|
|
|
_inviteOthersControl: any;
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* True if currently in a breakout room.
|
|
|
|
*/
|
2023-01-12 10:13:18 +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.
|
|
|
|
*/
|
2023-01-12 10:13:18 +00:00
|
|
|
_isInviteFunctionsDisabled: boolean;
|
2020-04-09 13:26:19 +00:00
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
/**
|
|
|
|
* True if it's a lonely meeting (participant count excluding fakes is 1).
|
|
|
|
*/
|
2023-01-12 10:13:18 +00:00
|
|
|
_isLonelyMeeting: boolean;
|
|
|
|
|
2020-03-20 17:30:46 +00:00
|
|
|
/**
|
|
|
|
* The Redux Dispatch function.
|
|
|
|
*/
|
2023-01-12 10:13:18 +00:00
|
|
|
dispatch: Function;
|
2020-03-20 17:30:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be used to translate i18n labels.
|
|
|
|
*/
|
2023-01-12 10:13:18 +00:00
|
|
|
t: Function;
|
2020-03-20 17:30:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@code PureComponent#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-09-14 15:31:30 +00:00
|
|
|
const {
|
2023-01-12 13:47:44 +00:00
|
|
|
_inviteOthersControl,
|
2021-09-14 15:31:30 +00:00
|
|
|
_isInBreakoutRoom,
|
2023-01-12 10:13:18 +00:00
|
|
|
_isInviteFunctionsDisabled,
|
2021-09-14 15:31:30 +00:00
|
|
|
_isLonelyMeeting,
|
|
|
|
t
|
|
|
|
} = this.props;
|
2023-01-12 13:47:44 +00:00
|
|
|
const { color, shareDialogVisible } = _inviteOthersControl;
|
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>
|
2023-01-12 10:13:18 +00:00
|
|
|
{ !_isInviteFunctionsDisabled && !_isInBreakoutRoom && (
|
2022-07-07 12:29:18 +00:00
|
|
|
<Button
|
|
|
|
accessibilityLabel = 'lonelyMeetingExperience.button'
|
2023-01-12 13:47:44 +00:00
|
|
|
disabled = { shareDialogVisible }
|
2023-01-12 10:13:18 +00:00
|
|
|
// eslint-disable-next-line react/jsx-no-bind
|
|
|
|
icon = { () => (
|
|
|
|
<Icon
|
|
|
|
color = { color }
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconAddUser } />
|
|
|
|
) }
|
2022-08-22 09:40:59 +00:00
|
|
|
labelKey = 'lonelyMeetingExperience.button'
|
|
|
|
onClick = { this._onPress }
|
2022-07-07 12:29:18 +00:00
|
|
|
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() {
|
2023-01-12 10:13:18 +00:00
|
|
|
this.props.dispatch(toggleShareDialog(true));
|
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}
|
|
|
|
*/
|
2023-01-12 10:13:18 +00:00
|
|
|
function _mapStateToProps(state: IReduxState) {
|
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'];
|
2023-01-12 13:47:44 +00:00
|
|
|
const _inviteOthersControl = getInviteOthersControl(state);
|
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 {
|
2023-01-12 13:47:44 +00:00
|
|
|
_inviteOthersControl,
|
2021-09-14 15:31:30 +00:00
|
|
|
_isInBreakoutRoom,
|
2023-01-12 10:13:18 +00:00
|
|
|
_isInviteFunctionsDisabled: !flag || disableInviteFunctions,
|
2023-01-12 13:47:44 +00:00
|
|
|
_isLonelyMeeting: conference && getParticipantCountWithFake(state) === 1
|
2020-03-20 17:30:46 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));
|