bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/breakout-room/container.jsx

140 lines
4.4 KiB
React
Raw Normal View History

import React from 'react';
2018-10-24 01:18:09 +08:00
import { withTracker } from 'meteor/react-meteor-data';
import AudioService from '/imports/ui/components/audio/service';
import AudioManager from '/imports/ui/services/audio-manager';
2024-01-15 20:47:17 +08:00
import { useMutation } from '@apollo/client';
2018-10-24 01:18:09 +08:00
import BreakoutComponent from './component';
import Service from './service';
2022-05-13 21:42:19 +08:00
import { layoutDispatch, layoutSelect } from '../layout/context';
import {
didUserSelectedMicrophone,
didUserSelectedListenOnly,
} from '/imports/ui/components/audio/audio-modal/service';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
2024-01-16 19:28:15 +08:00
import {
BREAKOUT_ROOM_END_ALL,
BREAKOUT_ROOM_SET_TIME,
USER_TRANSFER_VOICE_TO_MEETING,
2024-01-16 19:39:13 +08:00
BREAKOUT_ROOM_REQUEST_JOIN_URL,
2024-01-16 19:28:15 +08:00
} from './mutations';
2024-01-15 20:47:17 +08:00
import logger from '/imports/startup/client/logger';
2024-01-27 00:21:58 +08:00
import { CAMERA_BROADCAST_STOP } from '../video-provider/mutations';
2024-01-29 20:49:40 +08:00
import useToggleVoice from '../audio/audio-graphql/hooks/useToggleVoice';
2018-10-24 01:18:09 +08:00
2021-05-18 04:25:07 +08:00
const BreakoutContainer = (props) => {
2021-09-11 04:48:52 +08:00
const layoutContextDispatch = layoutDispatch();
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
isModerator: user.isModerator,
}));
const amIPresenter = currentUserData?.presenter;
const amIModerator = currentUserData?.isModerator;
2022-05-13 21:42:19 +08:00
const isRTL = layoutSelect((i) => i.isRTL);
2024-01-15 20:47:17 +08:00
const [breakoutRoomEndAll] = useMutation(BREAKOUT_ROOM_END_ALL);
2024-01-16 03:50:37 +08:00
const [breakoutRoomSetTime] = useMutation(BREAKOUT_ROOM_SET_TIME);
2024-01-16 19:28:15 +08:00
const [breakoutRoomTransfer] = useMutation(USER_TRANSFER_VOICE_TO_MEETING);
2024-01-16 19:39:13 +08:00
const [breakoutRoomRequestJoinURL] = useMutation(BREAKOUT_ROOM_REQUEST_JOIN_URL);
2024-01-27 00:21:58 +08:00
const [cameraBroadcastStop] = useMutation(CAMERA_BROADCAST_STOP);
2024-01-31 00:51:57 +08:00
const toggleVoice = useToggleVoice();
2024-01-27 00:21:58 +08:00
const sendUserUnshareWebcam = (cameraId) => {
cameraBroadcastStop({ variables: { cameraId } });
};
2024-01-15 20:47:17 +08:00
const endAllBreakouts = () => {
Service.setCapturedContentUploading();
breakoutRoomEndAll();
};
2024-01-16 03:50:37 +08:00
const setBreakoutsTime = (timeInMinutes) => {
if (timeInMinutes <= 0) return false;
return breakoutRoomSetTime({ variables: { timeInMinutes } });
};
2024-01-16 19:28:15 +08:00
const transferUserToMeeting = (fromMeeting, toMeeting) => {
breakoutRoomTransfer(
{
variables: {
fromMeetingId: fromMeeting,
toMeetingId: toMeeting,
},
},
);
};
2024-01-16 19:39:13 +08:00
const requestJoinURL = (breakoutRoomId) => {
breakoutRoomRequestJoinURL({ variables: { breakoutRoomId } });
};
2024-01-31 00:51:57 +08:00
const logUserCouldNotRejoinAudio = () => {
logger.warn({
logCode: 'mainroom_audio_rejoin',
extraInfo: { logType: 'user_action' },
}, 'leaving breakout room couldn\'t rejoin audio in the main room');
};
const rejoinAudio = () => {
if (didUserSelectedMicrophone()) {
AudioManager.joinMicrophone().then(() => {
toggleVoice(null, true).catch(() => {
AudioManager.forceExitAudio();
logUserCouldNotRejoinAudio();
});
}).catch(() => {
logUserCouldNotRejoinAudio();
});
} else if (didUserSelectedListenOnly()) {
AudioManager.joinListenOnly().catch(() => {
logUserCouldNotRejoinAudio();
});
}
};
2021-11-24 00:41:37 +08:00
return <BreakoutComponent
amIPresenter={amIPresenter}
2024-01-15 20:47:17 +08:00
endAllBreakouts={endAllBreakouts}
2024-01-16 03:50:37 +08:00
setBreakoutsTime={setBreakoutsTime}
2024-01-16 19:28:15 +08:00
transferUserToMeeting={transferUserToMeeting}
2024-01-16 19:39:13 +08:00
requestJoinURL={requestJoinURL}
2024-01-27 00:21:58 +08:00
sendUserUnshareWebcam={sendUserUnshareWebcam}
2024-01-31 00:51:57 +08:00
{...{ layoutContextDispatch, isRTL, amIModerator, rejoinAudio, ...props }}
2021-11-24 00:41:37 +08:00
/>;
2021-05-18 04:25:07 +08:00
};
2018-10-24 01:18:09 +08:00
export default withTracker((props) => {
const {
isNewTimeHigherThanMeetingRemaining,
findBreakouts,
getBreakoutRoomUrl,
2018-10-24 01:18:09 +08:00
meetingId,
isUserInBreakoutRoom,
2018-10-24 01:18:09 +08:00
} = Service;
const breakoutRooms = findBreakouts();
2023-07-31 22:24:25 +08:00
const isMicrophoneUser = (AudioService.isConnectedToBreakout() || AudioService.isConnected())
&& !AudioService.isListenOnly();
2019-06-27 00:29:34 +08:00
const isMeteorConnected = Meteor.status().connected;
const isReconnecting = AudioService.isReconnecting();
const {
setBreakoutAudioTransferStatus,
getBreakoutAudioTransferStatus,
} = AudioService;
2018-10-24 01:18:09 +08:00
return {
...props,
breakoutRooms,
isNewTimeHigherThanMeetingRemaining,
getBreakoutRoomUrl,
2018-10-24 01:18:09 +08:00
isMicrophoneUser,
meetingId: meetingId(),
2019-06-27 00:29:34 +08:00
isMeteorConnected,
isUserInBreakoutRoom,
forceExitAudio: () => AudioManager.forceExitAudio(),
isReconnecting,
setBreakoutAudioTransferStatus,
getBreakoutAudioTransferStatus,
2018-10-24 01:18:09 +08:00
};
})(BreakoutContainer);