2025-01-10 16:32:25 +01:00
|
|
|
/* eslint-disable lines-around-comment */
|
2023-05-08 16:33:45 +03:00
|
|
|
|
2020-09-16 17:13:15 +02:00
|
|
|
import React, { PureComponent } from 'react';
|
2023-05-02 11:09:38 +03:00
|
|
|
import { Text, TextStyle, View, ViewStyle } from 'react-native';
|
2021-07-30 12:46:49 +03:00
|
|
|
import { Divider } from 'react-native-paper';
|
2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
2018-12-19 19:40:17 +01:00
|
|
|
|
2023-05-22 09:54:11 +03:00
|
|
|
import { IReduxState, IStore } from '../../../app/types';
|
2023-03-31 14:04:33 +03:00
|
|
|
import Avatar from '../../../base/avatar/components/Avatar';
|
|
|
|
|
import { hideSheet } from '../../../base/dialog/actions';
|
|
|
|
|
import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
|
2022-06-14 12:20:16 +02:00
|
|
|
import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
|
2023-03-31 14:04:33 +03:00
|
|
|
import { KICK_OUT_ENABLED } from '../../../base/flags/constants';
|
|
|
|
|
import { getFeatureFlag } from '../../../base/flags/functions';
|
2023-04-03 13:49:19 +03:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
2021-07-30 12:46:49 +03:00
|
|
|
import {
|
|
|
|
|
getParticipantById,
|
2022-06-23 08:40:11 +01:00
|
|
|
getParticipantDisplayName,
|
2024-07-16 13:52:16 -07:00
|
|
|
hasRaisedHand,
|
2025-06-26 14:43:54 +03:00
|
|
|
isLocalParticipantModerator,
|
|
|
|
|
isPrivateChatEnabled
|
2023-04-03 13:49:19 +03:00
|
|
|
} from '../../../base/participants/functions';
|
2023-08-20 16:41:36 -04:00
|
|
|
import { getBreakoutRooms, getCurrentRoomId, isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
2023-05-02 11:09:38 +03:00
|
|
|
import { IRoom } from '../../../breakout-rooms/types';
|
2021-11-18 15:50:38 +01:00
|
|
|
import PrivateMessageButton from '../../../chat/components/native/PrivateMessageButton';
|
2018-12-19 19:40:17 +01:00
|
|
|
|
2021-09-22 17:05:42 +03:00
|
|
|
import AskUnmuteButton from './AskUnmuteButton';
|
2023-05-02 11:09:38 +03:00
|
|
|
import ConnectionStatusButton from './ConnectionStatusButton';
|
2024-02-28 14:59:35 -06:00
|
|
|
import DemoteToVisitorButton from './DemoteToVisitorButton';
|
2020-07-15 13:13:28 +03:00
|
|
|
import GrantModeratorButton from './GrantModeratorButton';
|
2018-12-19 19:40:17 +01:00
|
|
|
import KickButton from './KickButton';
|
2024-07-16 13:52:16 -07:00
|
|
|
import LowerHandButton from './LowerHandButton';
|
2018-12-19 19:40:17 +01:00
|
|
|
import MuteButton from './MuteButton';
|
2020-11-10 16:49:38 +02:00
|
|
|
import MuteEveryoneElseButton from './MuteEveryoneElseButton';
|
2021-07-30 12:46:49 +03:00
|
|
|
import MuteVideoButton from './MuteVideoButton';
|
2019-06-19 15:32:09 +02:00
|
|
|
import PinButton from './PinButton';
|
2021-09-14 17:31:30 +02:00
|
|
|
import SendToBreakoutRoom from './SendToBreakoutRoom';
|
2023-05-08 16:33:45 +03:00
|
|
|
import VolumeSlider from './VolumeSlider';
|
2018-12-19 19:40:17 +01:00
|
|
|
import styles from './styles';
|
|
|
|
|
|
2021-07-30 12:46:49 +03:00
|
|
|
|
2018-12-21 10:53:24 +01:00
|
|
|
/**
|
|
|
|
|
* Size of the rendered avatar in the menu.
|
|
|
|
|
*/
|
2021-07-30 12:46:49 +03:00
|
|
|
const AVATAR_SIZE = 24;
|
2018-12-21 10:53:24 +01:00
|
|
|
|
2023-05-02 11:09:38 +03:00
|
|
|
interface IProps {
|
2018-12-19 19:40:17 +01:00
|
|
|
|
|
|
|
|
/**
|
2023-05-02 11:09:38 +03:00
|
|
|
* The id of the current room.
|
2018-12-19 19:40:17 +01:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_currentRoomId: string;
|
2018-12-19 19:40:17 +01:00
|
|
|
|
2021-09-14 17:31:30 +02:00
|
|
|
/**
|
2023-05-02 11:09:38 +03:00
|
|
|
* Whether or not to display the grant moderator button.
|
2021-09-14 17:31:30 +02:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_disableGrantModerator: boolean;
|
2021-09-14 17:31:30 +02:00
|
|
|
|
2020-03-25 16:28:31 -05:00
|
|
|
/**
|
|
|
|
|
* Whether or not to display the kick button.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_disableKick: boolean;
|
2020-03-25 16:28:31 -05:00
|
|
|
|
2022-03-14 16:46:19 +02:00
|
|
|
/**
|
2025-06-26 14:43:54 +03:00
|
|
|
* Whether or not to display the remote mute buttons.
|
2022-03-14 16:46:19 +02:00
|
|
|
*/
|
2025-06-26 14:43:54 +03:00
|
|
|
_disableRemoteMute: boolean;
|
2022-03-14 16:46:19 +02:00
|
|
|
|
2020-03-25 16:28:31 -05:00
|
|
|
/**
|
2025-06-26 14:43:54 +03:00
|
|
|
* Whether or not to display the send private message button.
|
2020-03-25 16:28:31 -05:00
|
|
|
*/
|
2025-06-26 14:43:54 +03:00
|
|
|
_enablePrivateChat: boolean;
|
2021-04-30 18:22:36 +02:00
|
|
|
|
2023-08-20 16:41:36 -04:00
|
|
|
/**
|
|
|
|
|
* Whether or not the current room is a breakout room.
|
|
|
|
|
*/
|
|
|
|
|
_isBreakoutRoom: boolean;
|
|
|
|
|
|
2021-07-30 12:46:49 +03:00
|
|
|
/**
|
|
|
|
|
* Whether the participant is present in the room or not.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_isParticipantAvailable?: boolean;
|
2021-07-30 12:46:49 +03:00
|
|
|
|
2024-07-02 09:22:10 -04:00
|
|
|
/**
|
|
|
|
|
* Whether or not the targeted participant joined without audio.
|
|
|
|
|
*/
|
|
|
|
|
_isParticipantSilent: boolean;
|
|
|
|
|
|
2022-06-23 08:40:11 +01:00
|
|
|
/**
|
|
|
|
|
* Whether the local participant is moderator or not.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_moderator: boolean;
|
2022-06-23 08:40:11 +01:00
|
|
|
|
2018-12-19 19:40:17 +01:00
|
|
|
/**
|
2021-03-16 11:59:33 -04:00
|
|
|
* Display name of the participant retrieved from Redux.
|
2018-12-19 19:40:17 +01:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_participantDisplayName: string;
|
2021-09-14 17:31:30 +02:00
|
|
|
|
2024-07-16 13:52:16 -07:00
|
|
|
/**
|
|
|
|
|
* Whether the targeted participant raised hand or not.
|
|
|
|
|
*/
|
|
|
|
|
_raisedHand: boolean;
|
|
|
|
|
|
2021-09-14 17:31:30 +02:00
|
|
|
/**
|
|
|
|
|
* Array containing the breakout rooms.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_rooms: Array<IRoom>;
|
|
|
|
|
|
2024-02-28 14:59:35 -06:00
|
|
|
/**
|
|
|
|
|
* Whether to display the demote button.
|
|
|
|
|
*/
|
|
|
|
|
_showDemote: boolean;
|
|
|
|
|
|
2023-05-02 11:09:38 +03:00
|
|
|
/**
|
|
|
|
|
* The Redux dispatch function.
|
|
|
|
|
*/
|
2023-05-22 09:54:11 +03:00
|
|
|
dispatch: IStore['dispatch'];
|
2023-05-02 11:09:38 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The ID of the participant for which this menu opened for.
|
|
|
|
|
*/
|
|
|
|
|
participantId: string;
|
2021-09-14 17:31:30 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Translation function.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
t: Function;
|
2018-12-19 19:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to implement a popup menu that opens upon long pressing a thumbnail.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
class RemoteVideoMenu extends PureComponent<IProps> {
|
2018-12-19 19:40:17 +01:00
|
|
|
/**
|
|
|
|
|
* Constructor of the component.
|
|
|
|
|
*
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
constructor(props: IProps) {
|
2018-12-19 19:40:17 +01:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this._onCancel = this._onCancel.bind(this);
|
2020-09-16 17:13:15 +02:00
|
|
|
this._renderMenuHeader = this._renderMenuHeader.bind(this);
|
2018-12-19 19:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements {@code Component#render}.
|
|
|
|
|
*
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
2025-03-12 10:19:11 -05:00
|
|
|
override render() {
|
2021-07-30 12:46:49 +03:00
|
|
|
const {
|
|
|
|
|
_disableKick,
|
|
|
|
|
_disableRemoteMute,
|
|
|
|
|
_disableGrantModerator,
|
2025-06-26 14:43:54 +03:00
|
|
|
_enablePrivateChat,
|
2023-08-20 16:41:36 -04:00
|
|
|
_isBreakoutRoom,
|
2021-07-30 12:46:49 +03:00
|
|
|
_isParticipantAvailable,
|
2024-07-02 09:22:10 -04:00
|
|
|
_isParticipantSilent,
|
2022-06-23 08:40:11 +01:00
|
|
|
_moderator,
|
2024-07-16 13:52:16 -07:00
|
|
|
_raisedHand,
|
2021-09-14 17:31:30 +02:00
|
|
|
_rooms,
|
2024-02-28 14:59:35 -06:00
|
|
|
_showDemote,
|
2021-09-14 17:31:30 +02:00
|
|
|
_currentRoomId,
|
|
|
|
|
participantId,
|
|
|
|
|
t
|
2021-07-30 12:46:49 +03:00
|
|
|
} = this.props;
|
2018-12-19 19:40:17 +01:00
|
|
|
const buttonProps = {
|
|
|
|
|
afterClick: this._onCancel,
|
|
|
|
|
showLabel: true,
|
2021-08-20 18:32:38 -05:00
|
|
|
participantID: participantId,
|
2022-06-14 12:20:16 +02:00
|
|
|
styles: bottomSheetStyles.buttons
|
2018-12-19 19:40:17 +01:00
|
|
|
};
|
|
|
|
|
|
2023-05-08 16:33:45 +03:00
|
|
|
const connectionStatusButtonProps = {
|
|
|
|
|
...buttonProps,
|
|
|
|
|
afterClick: undefined
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-19 19:40:17 +01:00
|
|
|
return (
|
2020-09-16 17:13:15 +02:00
|
|
|
<BottomSheet
|
2021-07-30 12:46:49 +03:00
|
|
|
renderHeader = { this._renderMenuHeader }
|
|
|
|
|
showSlidingView = { _isParticipantAvailable }>
|
2024-07-02 09:22:10 -04:00
|
|
|
{!_isParticipantSilent && <AskUnmuteButton { ...buttonProps } />}
|
2020-09-16 17:13:15 +02:00
|
|
|
{ !_disableRemoteMute && <MuteButton { ...buttonProps } /> }
|
2021-07-30 12:46:49 +03:00
|
|
|
<MuteEveryoneElseButton { ...buttonProps } />
|
2024-07-16 13:52:16 -07:00
|
|
|
{ _moderator && _raisedHand && <LowerHandButton { ...buttonProps } /> }
|
2024-07-02 09:22:10 -04:00
|
|
|
{ !_disableRemoteMute && !_isParticipantSilent && <MuteVideoButton { ...buttonProps } /> }
|
2023-05-02 11:09:38 +03:00
|
|
|
{/* @ts-ignore */}
|
|
|
|
|
<Divider style = { styles.divider as ViewStyle } />
|
2020-09-16 17:13:15 +02:00
|
|
|
{ !_disableKick && <KickButton { ...buttonProps } /> }
|
2023-08-20 16:41:36 -04:00
|
|
|
{ !_disableGrantModerator && !_isBreakoutRoom && <GrantModeratorButton { ...buttonProps } /> }
|
2020-09-16 17:13:15 +02:00
|
|
|
<PinButton { ...buttonProps } />
|
2024-02-28 14:59:35 -06:00
|
|
|
{ _showDemote && <DemoteToVisitorButton { ...buttonProps } /> }
|
2025-06-26 14:43:54 +03:00
|
|
|
{ _enablePrivateChat && <PrivateMessageButton { ...buttonProps } /> }
|
2023-05-08 16:33:45 +03:00
|
|
|
<ConnectionStatusButton { ...connectionStatusButtonProps } />
|
2022-06-23 08:40:11 +01:00
|
|
|
{_moderator && _rooms.length > 1 && <>
|
2023-05-02 11:09:38 +03:00
|
|
|
{/* @ts-ignore */}
|
|
|
|
|
<Divider style = { styles.divider as ViewStyle } />
|
|
|
|
|
<View style = { styles.contextMenuItem as ViewStyle }>
|
|
|
|
|
<Text style = { styles.contextMenuItemText as TextStyle }>
|
2021-09-14 17:31:30 +02:00
|
|
|
{t('breakoutRooms.actions.sendToBreakoutRoom')}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
{_rooms.map(room => _currentRoomId !== room.id && (<SendToBreakoutRoom
|
|
|
|
|
key = { room.id }
|
|
|
|
|
room = { room }
|
|
|
|
|
{ ...buttonProps } />))}
|
|
|
|
|
</>}
|
2023-05-08 16:33:45 +03:00
|
|
|
<VolumeSlider participantID = { participantId } />
|
2018-12-19 19:40:17 +01:00
|
|
|
</BottomSheet>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Callback to hide the {@code RemoteVideoMenu}.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
2019-07-11 13:32:17 +02:00
|
|
|
* @returns {boolean}
|
2018-12-19 19:40:17 +01:00
|
|
|
*/
|
|
|
|
|
_onCancel() {
|
2022-06-20 16:53:19 +02:00
|
|
|
this.props.dispatch(hideSheet());
|
2018-12-19 19:40:17 +01:00
|
|
|
}
|
2020-09-16 17:13:15 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function to render the menu's header.
|
|
|
|
|
*
|
|
|
|
|
* @returns {React$Element}
|
|
|
|
|
*/
|
|
|
|
|
_renderMenuHeader() {
|
2022-06-14 12:20:16 +02:00
|
|
|
const { participantId } = this.props;
|
2020-09-16 17:13:15 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<View
|
|
|
|
|
style = { [
|
2022-06-14 12:20:16 +02:00
|
|
|
bottomSheetStyles.sheet,
|
2023-05-02 11:09:38 +03:00
|
|
|
styles.participantNameContainer ] as ViewStyle[] }>
|
2020-09-16 17:13:15 +02:00
|
|
|
<Avatar
|
2021-08-20 18:32:38 -05:00
|
|
|
participantId = { participantId }
|
2020-09-16 17:13:15 +02:00
|
|
|
size = { AVATAR_SIZE } />
|
2023-05-02 11:09:38 +03:00
|
|
|
<Text style = { styles.participantNameLabel as TextStyle }>
|
2020-09-16 17:13:15 +02:00
|
|
|
{ this.props._participantDisplayName }
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
}
|
2018-12-19 19:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
|
* @param {Object} ownProps - Properties of component.
|
|
|
|
|
* @private
|
2023-05-02 11:09:38 +03:00
|
|
|
* @returns {IProps}
|
2018-12-19 19:40:17 +01:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
function _mapStateToProps(state: IReduxState, ownProps: any) {
|
2020-10-07 00:10:44 +05:30
|
|
|
const kickOutEnabled = getFeatureFlag(state, KICK_OUT_ENABLED, true);
|
2021-08-20 18:32:38 -05:00
|
|
|
const { participantId } = ownProps;
|
2020-03-25 16:28:31 -05:00
|
|
|
const { remoteVideoMenu = {}, disableRemoteMute } = state['features/base/config'];
|
2024-07-02 09:22:10 -04:00
|
|
|
const participant = getParticipantById(state, participantId);
|
2025-06-26 14:43:54 +03:00
|
|
|
const { disableKick } = remoteVideoMenu;
|
2021-09-14 17:31:30 +02:00
|
|
|
const _rooms = Object.values(getBreakoutRooms(state));
|
|
|
|
|
const _currentRoomId = getCurrentRoomId(state);
|
2022-03-14 16:46:19 +02:00
|
|
|
const shouldDisableKick = disableKick || !kickOutEnabled;
|
2022-06-23 08:40:11 +01:00
|
|
|
const moderator = isLocalParticipantModerator(state);
|
2023-03-28 08:08:56 -05:00
|
|
|
const _iAmVisitor = state['features/visitors'].iAmVisitor;
|
2023-08-20 16:41:36 -04:00
|
|
|
const _isBreakoutRoom = isInBreakoutRoom(state);
|
2024-07-16 13:52:16 -07:00
|
|
|
const raisedHand = hasRaisedHand(participant);
|
2018-12-19 19:40:17 +01:00
|
|
|
|
|
|
|
|
return {
|
2021-09-14 17:31:30 +02:00
|
|
|
_currentRoomId,
|
2022-03-14 16:46:19 +02:00
|
|
|
_disableKick: Boolean(shouldDisableKick),
|
2020-03-25 16:28:31 -05:00
|
|
|
_disableRemoteMute: Boolean(disableRemoteMute),
|
2025-06-26 14:43:54 +03:00
|
|
|
_enablePrivateChat: isPrivateChatEnabled(participant, state),
|
2023-08-20 16:41:36 -04:00
|
|
|
_isBreakoutRoom,
|
2024-07-02 09:22:10 -04:00
|
|
|
_isParticipantAvailable: Boolean(participant),
|
|
|
|
|
_isParticipantSilent: Boolean(participant?.isSilent),
|
2022-06-23 08:40:11 +01:00
|
|
|
_moderator: moderator,
|
2021-09-14 17:31:30 +02:00
|
|
|
_participantDisplayName: getParticipantDisplayName(state, participantId),
|
2024-07-16 13:52:16 -07:00
|
|
|
_raisedHand: raisedHand,
|
2024-02-28 14:59:35 -06:00
|
|
|
_rooms,
|
|
|
|
|
_showDemote: moderator
|
2018-12-19 19:40:17 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-20 16:53:19 +02:00
|
|
|
export default translate(connect(_mapStateToProps)(RemoteVideoMenu));
|