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

102 lines
3.0 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';
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';
2022-02-12 00:37:22 +08:00
import { makeCall } from '/imports/ui/services/api';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
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);
2021-11-24 00:41:37 +08:00
return <BreakoutComponent
amIPresenter={amIPresenter}
{...{ layoutContextDispatch, isRTL, amIModerator, ...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 {
endAllBreakouts,
requestJoinURL,
setBreakoutsTime,
sendMessageToAllBreakouts,
isNewTimeHigherThanMeetingRemaining,
findBreakouts,
getBreakoutRoomUrl,
2018-10-24 01:18:09 +08:00
transferUserToMeeting,
transferToBreakout,
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
2022-02-12 00:32:02 +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(() => {
makeCall('toggleVoice', null, true).catch(() => {
2022-02-12 00:37:22 +08:00
AudioManager.forceExitAudio();
2022-02-12 00:32:02 +08:00
logUserCouldNotRejoinAudio();
});
}).catch(() => {
2022-02-12 00:32:02 +08:00
logUserCouldNotRejoinAudio();
});
} else if (didUserSelectedListenOnly()) {
AudioManager.joinListenOnly().catch(() => {
2022-02-12 00:32:02 +08:00
logUserCouldNotRejoinAudio();
});
}
};
2018-10-24 01:18:09 +08:00
return {
...props,
breakoutRooms,
endAllBreakouts,
requestJoinURL,
setBreakoutsTime,
sendMessageToAllBreakouts,
isNewTimeHigherThanMeetingRemaining,
getBreakoutRoomUrl,
2018-10-24 01:18:09 +08:00
transferUserToMeeting,
transferToBreakout,
isMicrophoneUser,
meetingId: meetingId(),
2019-06-27 00:29:34 +08:00
isMeteorConnected,
isUserInBreakoutRoom,
forceExitAudio: () => AudioManager.forceExitAudio(),
rejoinAudio,
isReconnecting,
setBreakoutAudioTransferStatus,
getBreakoutAudioTransferStatus,
2018-10-24 01:18:09 +08:00
};
})(BreakoutContainer);