jiti-meet/react/features/conference/components/native/LonelyMeetingExperience.js

141 lines
3.7 KiB
JavaScript
Raw Normal View History

2020-03-20 17:30:46 +00:00
import React, { PureComponent } from 'react';
import { Text, View } from 'react-native';
2020-03-20 17:30:46 +00:00
import { INVITE_ENABLED, getFeatureFlag } from '../../../base/flags';
import { translate } from '../../../base/i18n';
2020-05-20 10:57:03 +00:00
import { Icon, IconAddPeople } from '../../../base/icons';
import { getParticipantCountWithFake } from '../../../base/participants';
2020-03-20 17:30:46 +00:00
import { connect } from '../../../base/redux';
import Button from '../../../base/ui/components/native/Button';
import { BUTTON_TYPES } from '../../../base/ui/constants';
import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
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 = {
/**
* True if currently in a breakout room.
*/
_isInBreakoutRoom: boolean,
/**
* 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);
}
/**
* 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() {
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>
{ !_isInviteFunctionsDiabled && !_isInBreakoutRoom && (
<Button
accessibilityLabel = 'lonelyMeetingExperience.button'
icon = { this._renderAddPeopleIcon }
labelKey = 'lonelyMeetingExperience.button'
onClick = { this._onPress }
style = { styles.lonelyButton }
type = { BUTTON_TYPES.PRIMARY } />
) }
2020-03-20 17:30:46 +00:00
</View>
);
}
/**
* Callback for the onPress function of the button.
*
* @returns {void}
*/
_onPress() {
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) {
const { disableInviteFunctions } = state['features/base/config'];
const { conference } = state['features/base/conference'];
const flag = getFeatureFlag(state, INVITE_ENABLED, true);
const _isInBreakoutRoom = isInBreakoutRoom(state);
2020-03-20 17:30:46 +00:00
return {
_isInBreakoutRoom,
_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));