2022-01-20 14:26:03 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-11-25 11:59:45 +00:00
|
|
|
import { View } from 'react-native';
|
2020-04-15 13:13:43 +00:00
|
|
|
|
2022-11-25 11:59:45 +00:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
import { isLocalParticipantModerator } from '../../../base/participants/functions';
|
2020-04-15 13:13:43 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2022-11-25 11:59:45 +00:00
|
|
|
import Button from '../../../base/ui/components/native/Button';
|
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
|
|
|
|
import { handleLobbyChatInitialized } from '../../../chat/actions.native';
|
2022-03-03 17:29:38 +00:00
|
|
|
import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
|
|
|
|
import { screen } from '../../../mobile/navigation/routes';
|
2022-11-25 11:59:45 +00:00
|
|
|
import ParticipantItem
|
|
|
|
from '../../../participants-pane/components/native/ParticipantItem';
|
|
|
|
import { setKnockingParticipantApproval } from '../../actions.native';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { getKnockingParticipants, getLobbyEnabled, showLobbyChatButton } from '../../functions';
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
2022-11-25 11:59:45 +00:00
|
|
|
|
2022-01-20 14:26:03 +00:00
|
|
|
/**
|
|
|
|
* Props type of the component.
|
|
|
|
*/
|
|
|
|
export type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of participants.
|
|
|
|
*/
|
|
|
|
_participants: Array<Object>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the list should be rendered.
|
|
|
|
*/
|
|
|
|
_visible: boolean,
|
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
/**
|
|
|
|
* True if the polls feature is disabled.
|
|
|
|
*/
|
|
|
|
_isPollsDisabled: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the lobby chat button should be shown.
|
|
|
|
*/
|
|
|
|
_showChatButton: Function,
|
|
|
|
|
2022-01-20 14:26:03 +00:00
|
|
|
/**
|
|
|
|
* The Redux Dispatch function.
|
|
|
|
*/
|
2022-11-25 11:59:45 +00:00
|
|
|
dispatch: Function
|
2022-01-20 14:26:03 +00:00
|
|
|
};
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* Component to render a list for the actively knocking participants.
|
|
|
|
*/
|
2022-01-20 14:26:03 +00:00
|
|
|
class KnockingParticipantList extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onRespondToParticipant = this._onRespondToParticipant.bind(this);
|
|
|
|
}
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* Implements {@code PureComponent#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2022-11-25 11:59:45 +00:00
|
|
|
const { _participants, _visible, _showChatButton } = this.props;
|
2020-04-15 13:13:43 +00:00
|
|
|
|
2020-05-20 08:25:31 +00:00
|
|
|
if (!_visible) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
return (
|
2022-11-25 11:59:45 +00:00
|
|
|
<>
|
2020-05-20 08:25:31 +00:00
|
|
|
{ _participants.map(p => (
|
2020-04-15 13:13:43 +00:00
|
|
|
<View
|
|
|
|
key = { p.id }
|
|
|
|
style = { styles.knockingParticipantListEntry }>
|
2022-11-25 11:59:45 +00:00
|
|
|
<ParticipantItem
|
2020-04-15 13:13:43 +00:00
|
|
|
displayName = { p.name }
|
2022-11-25 11:59:45 +00:00
|
|
|
isKnockingParticipant = { true }
|
|
|
|
key = { p.id }
|
|
|
|
participantID = { p.id }>
|
|
|
|
<Button
|
|
|
|
labelKey = { 'lobby.admit' }
|
|
|
|
onClick = { this._onRespondToParticipant(p.id, true) }
|
|
|
|
style = { styles.lobbyButtonAdmit }
|
|
|
|
type = { BUTTON_TYPES.PRIMARY } />
|
|
|
|
{
|
|
|
|
_showChatButton(p)
|
|
|
|
? (
|
|
|
|
<Button
|
|
|
|
labelKey = { 'lobby.chat' }
|
|
|
|
onClick = { this._onInitializeLobbyChat(p.id) }
|
|
|
|
style = { styles.lobbyButtonChat }
|
|
|
|
type = { BUTTON_TYPES.SECONDARY } />
|
|
|
|
) : null
|
|
|
|
}
|
|
|
|
<Button
|
|
|
|
labelKey = { 'lobby.reject' }
|
|
|
|
onClick = { this._onRespondToParticipant(p.id, false) }
|
|
|
|
style = { styles.lobbyButtonReject }
|
|
|
|
type = { BUTTON_TYPES.DESTRUCTIVE } />
|
|
|
|
</ParticipantItem>
|
2020-04-15 13:13:43 +00:00
|
|
|
</View>
|
|
|
|
)) }
|
2022-11-25 11:59:45 +00:00
|
|
|
</>
|
2020-04-15 13:13:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onRespondToParticipant: (string, boolean) => Function;
|
2022-01-20 14:26:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that constructs a callback for the response handler button.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the knocking participant.
|
|
|
|
* @param {boolean} approve - The response for the knocking.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
_onRespondToParticipant(id, approve) {
|
|
|
|
return () => {
|
|
|
|
this.props.dispatch(setKnockingParticipantApproval(id, approve));
|
|
|
|
};
|
|
|
|
}
|
2022-03-03 17:29:38 +00:00
|
|
|
|
|
|
|
_onInitializeLobbyChat: (string) => Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that constructs a callback for the lobby chat button.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the knocking participant.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
_onInitializeLobbyChat(id) {
|
|
|
|
return () => {
|
|
|
|
this.props.dispatch(handleLobbyChatInitialized(id));
|
|
|
|
if (this.props._isPollsDisabled) {
|
|
|
|
return navigate(screen.conference.chat);
|
|
|
|
}
|
2022-11-25 11:59:45 +00:00
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
navigate(screen.conference.chatandpolls.main);
|
|
|
|
};
|
|
|
|
}
|
2020-04-15 13:13:43 +00:00
|
|
|
}
|
|
|
|
|
2020-05-20 08:25:31 +00:00
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-01-20 14:26:03 +00:00
|
|
|
function _mapStateToProps(state): Object {
|
|
|
|
const lobbyEnabled = getLobbyEnabled(state);
|
|
|
|
const knockingParticipants = getKnockingParticipants(state);
|
2022-03-03 17:29:38 +00:00
|
|
|
const { disablePolls } = state['features/base/config'];
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
return {
|
2022-01-20 14:26:03 +00:00
|
|
|
_visible: lobbyEnabled && isLocalParticipantModerator(state),
|
2022-03-03 17:29:38 +00:00
|
|
|
_showChatButton: participant => showLobbyChatButton(participant)(state),
|
|
|
|
_isPollsDisabled: disablePolls,
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
// On mobile we only show a portion of the list for screen real estate reasons
|
2022-01-20 14:26:03 +00:00
|
|
|
_participants: knockingParticipants.slice(0, 2)
|
2020-05-20 08:25:31 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(KnockingParticipantList));
|