2021-05-12 16:13:03 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { useCallback } from 'react';
|
2021-05-19 10:08:30 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2021-10-20 19:29:21 +00:00
|
|
|
import { ScrollView, View } from 'react-native';
|
2021-05-26 07:15:37 +00:00
|
|
|
import { Button } from 'react-native-paper';
|
2021-06-11 13:12:00 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2021-05-12 16:13:03 +00:00
|
|
|
|
2021-06-11 13:12:00 +00:00
|
|
|
import { openDialog } from '../../../base/dialog';
|
2021-10-20 19:29:21 +00:00
|
|
|
import JitsiScreen from '../../../base/modal/components/JitsiScreen';
|
2021-06-11 07:15:20 +00:00
|
|
|
import {
|
2021-09-14 15:31:30 +00:00
|
|
|
getParticipantCount,
|
2021-06-11 07:15:20 +00:00
|
|
|
isLocalParticipantModerator
|
|
|
|
} from '../../../base/participants';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { equals } from '../../../base/redux';
|
|
|
|
import {
|
|
|
|
AddBreakoutRoomButton,
|
|
|
|
AutoAssignButton,
|
|
|
|
LeaveBreakoutRoomButton
|
|
|
|
} from '../../../breakout-rooms/components/native';
|
|
|
|
import { CollapsibleRoom } from '../../../breakout-rooms/components/native/CollapsibleRoom';
|
|
|
|
import { getBreakoutRooms, getCurrentRoomId, isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
2021-05-26 10:03:12 +00:00
|
|
|
import MuteEveryoneDialog
|
|
|
|
from '../../../video-menu/components/native/MuteEveryoneDialog';
|
2021-05-12 16:13:03 +00:00
|
|
|
|
2021-06-03 16:26:11 +00:00
|
|
|
import { ContextMenuMore } from './ContextMenuMore';
|
2021-09-22 14:05:42 +00:00
|
|
|
import HorizontalDotsIcon from './HorizontalDotsIcon';
|
2021-07-30 09:48:06 +00:00
|
|
|
import LobbyParticipantList from './LobbyParticipantList';
|
2021-08-04 08:51:05 +00:00
|
|
|
import MeetingParticipantList from './MeetingParticipantList';
|
2021-07-02 13:43:52 +00:00
|
|
|
import styles from './styles';
|
2021-05-14 16:03:23 +00:00
|
|
|
|
2021-05-12 16:13:03 +00:00
|
|
|
/**
|
|
|
|
* Participant pane.
|
|
|
|
*
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
*/
|
2021-06-11 13:12:00 +00:00
|
|
|
const ParticipantsPane = () => {
|
2021-05-12 16:13:03 +00:00
|
|
|
const dispatch = useDispatch();
|
2021-06-09 15:35:58 +00:00
|
|
|
const openMoreMenu = useCallback(() => dispatch(openDialog(ContextMenuMore)), [ dispatch ]);
|
|
|
|
const isLocalModerator = useSelector(isLocalParticipantModerator);
|
2021-05-26 10:03:12 +00:00
|
|
|
const muteAll = useCallback(() => dispatch(openDialog(MuteEveryoneDialog)),
|
|
|
|
[ dispatch ]);
|
2021-05-19 10:08:30 +00:00
|
|
|
const { t } = useTranslation();
|
2021-05-14 16:03:23 +00:00
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
const { hideAddRoomButton } = useSelector(state => state['features/base/config']);
|
|
|
|
const { conference } = useSelector(state => state['features/base/conference']);
|
|
|
|
|
|
|
|
// $FlowExpectedError
|
|
|
|
const _isBreakoutRoomsSupported = conference?.getBreakoutRooms()?.isSupported();
|
|
|
|
const currentRoomId = useSelector(getCurrentRoomId);
|
|
|
|
const rooms: Array<Object> = Object.values(useSelector(getBreakoutRooms, equals))
|
|
|
|
.filter((room: Object) => room.id !== currentRoomId)
|
|
|
|
.sort((p1: Object, p2: Object) => (p1?.name || '').localeCompare(p2?.name || ''));
|
|
|
|
const inBreakoutRoom = useSelector(isInBreakoutRoom);
|
|
|
|
const participantsCount = useSelector(getParticipantCount);
|
|
|
|
|
2021-05-12 16:13:03 +00:00
|
|
|
return (
|
2021-10-20 19:29:21 +00:00
|
|
|
<JitsiScreen
|
2021-05-14 16:03:23 +00:00
|
|
|
style = { styles.participantsPane }>
|
2021-10-20 19:29:21 +00:00
|
|
|
<ScrollView bounces = { false }>
|
|
|
|
<LobbyParticipantList />
|
|
|
|
<MeetingParticipantList />
|
2021-09-14 15:31:30 +00:00
|
|
|
{!inBreakoutRoom
|
|
|
|
&& isLocalModerator
|
|
|
|
&& participantsCount > 2
|
|
|
|
&& rooms.length > 1
|
|
|
|
&& <AutoAssignButton />}
|
|
|
|
{inBreakoutRoom && <LeaveBreakoutRoomButton />}
|
|
|
|
{_isBreakoutRoomsSupported
|
|
|
|
&& rooms.map(room => (<CollapsibleRoom
|
|
|
|
key = { room.id }
|
|
|
|
room = { room } />))}
|
|
|
|
{_isBreakoutRoomsSupported && !hideAddRoomButton && isLocalModerator
|
|
|
|
&& <AddBreakoutRoomButton />}
|
2021-10-20 19:29:21 +00:00
|
|
|
</ScrollView>
|
2021-06-09 15:35:58 +00:00
|
|
|
{
|
|
|
|
isLocalModerator
|
|
|
|
&& <View style = { styles.footer }>
|
|
|
|
<Button
|
|
|
|
children = { t('participantsPane.actions.muteAll') }
|
|
|
|
labelStyle = { styles.muteAllLabel }
|
|
|
|
mode = 'contained'
|
|
|
|
onPress = { muteAll }
|
2021-09-22 14:05:42 +00:00
|
|
|
style = { styles.muteAllMoreButton } />
|
|
|
|
<Button
|
|
|
|
icon = { HorizontalDotsIcon }
|
|
|
|
labelStyle = { styles.moreIcon }
|
|
|
|
mode = 'contained'
|
|
|
|
onPress = { openMoreMenu }
|
|
|
|
style = { styles.moreButton } />
|
2021-06-09 15:35:58 +00:00
|
|
|
</View>
|
|
|
|
}
|
2021-10-20 19:29:21 +00:00
|
|
|
</JitsiScreen>
|
2021-05-12 16:13:03 +00:00
|
|
|
);
|
2021-06-11 13:12:00 +00:00
|
|
|
};
|
2021-05-12 16:13:03 +00:00
|
|
|
|
2021-06-11 13:12:00 +00:00
|
|
|
export default ParticipantsPane;
|