2021-11-24 00:41:37 +08:00
|
|
|
import React, { useContext } 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';
|
2019-10-18 04:42:14 +08:00
|
|
|
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';
|
2021-11-24 00:41:37 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
2022-02-12 00:27:34 +08:00
|
|
|
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';
|
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();
|
2021-11-24 00:41:37 +08:00
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const { users } = usingUsersContext;
|
|
|
|
const amIPresenter = users[Auth.meetingID][Auth.userID].presenter;
|
2022-05-13 21:42:19 +08:00
|
|
|
const isRTL = layoutSelect((i) => i.isRTL);
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-11-24 00:41:37 +08:00
|
|
|
return <BreakoutComponent
|
|
|
|
amIPresenter={amIPresenter}
|
2022-05-13 21:42:19 +08:00
|
|
|
{...{ layoutContextDispatch, isRTL, ...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,
|
2022-02-21 19:14:34 +08:00
|
|
|
setBreakoutsTime,
|
2022-01-27 04:02:38 +08:00
|
|
|
sendMessageToAllBreakouts,
|
2022-02-21 19:14:34 +08:00
|
|
|
isNewTimeHigherThanMeetingRemaining,
|
2018-10-30 03:36:45 +08:00
|
|
|
findBreakouts,
|
2021-10-01 21:44:01 +08:00
|
|
|
getBreakoutRoomUrl,
|
2018-10-24 01:18:09 +08:00
|
|
|
transferUserToMeeting,
|
|
|
|
transferToBreakout,
|
|
|
|
meetingId,
|
2019-09-07 04:28:02 +08:00
|
|
|
amIModerator,
|
2019-09-19 02:55:06 +08:00
|
|
|
isUserInBreakoutRoom,
|
2018-10-24 01:18:09 +08:00
|
|
|
} = Service;
|
2019-10-18 04:42:14 +08:00
|
|
|
|
2018-10-30 03:36:45 +08:00
|
|
|
const breakoutRooms = findBreakouts();
|
2018-10-24 01:18:09 +08:00
|
|
|
const isMicrophoneUser = AudioService.isConnected() && !AudioService.isListenOnly();
|
2019-06-27 00:29:34 +08:00
|
|
|
const isMeteorConnected = Meteor.status().connected;
|
2021-03-05 11:06:19 +08:00
|
|
|
const isReconnecting = AudioService.isReconnecting();
|
2021-03-07 09:09:43 +08:00
|
|
|
const {
|
|
|
|
setBreakoutAudioTransferStatus,
|
|
|
|
getBreakoutAudioTransferStatus,
|
|
|
|
} = AudioService;
|
2018-10-24 01:18:09 +08:00
|
|
|
|
2022-02-12 00:32:02 +08:00
|
|
|
const logUserCouldNotRejoinAudio = () => {
|
2022-02-12 00:27:34 +08:00
|
|
|
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();
|
2022-02-12 00:27:34 +08:00
|
|
|
});
|
|
|
|
}).catch(() => {
|
2022-02-12 00:32:02 +08:00
|
|
|
logUserCouldNotRejoinAudio();
|
2022-02-12 00:27:34 +08:00
|
|
|
});
|
|
|
|
} else if (didUserSelectedListenOnly()) {
|
|
|
|
AudioManager.joinListenOnly().catch(() => {
|
2022-02-12 00:32:02 +08:00
|
|
|
logUserCouldNotRejoinAudio();
|
2022-02-12 00:27:34 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-24 01:18:09 +08:00
|
|
|
return {
|
|
|
|
...props,
|
|
|
|
breakoutRooms,
|
|
|
|
endAllBreakouts,
|
|
|
|
requestJoinURL,
|
2022-02-21 19:14:34 +08:00
|
|
|
setBreakoutsTime,
|
2022-01-27 04:02:38 +08:00
|
|
|
sendMessageToAllBreakouts,
|
2022-02-21 19:14:34 +08:00
|
|
|
isNewTimeHigherThanMeetingRemaining,
|
2021-10-01 21:44:01 +08:00
|
|
|
getBreakoutRoomUrl,
|
2018-10-24 01:18:09 +08:00
|
|
|
transferUserToMeeting,
|
|
|
|
transferToBreakout,
|
|
|
|
isMicrophoneUser,
|
2018-11-05 20:27:56 +08:00
|
|
|
meetingId: meetingId(),
|
2019-09-07 04:28:02 +08:00
|
|
|
amIModerator: amIModerator(),
|
2019-06-27 00:29:34 +08:00
|
|
|
isMeteorConnected,
|
2019-09-19 02:55:06 +08:00
|
|
|
isUserInBreakoutRoom,
|
2022-02-09 22:43:54 +08:00
|
|
|
forceExitAudio: () => AudioManager.forceExitAudio(),
|
2022-02-12 00:27:34 +08:00
|
|
|
rejoinAudio,
|
2021-03-05 11:06:19 +08:00
|
|
|
isReconnecting,
|
2021-03-07 09:09:43 +08:00
|
|
|
setBreakoutAudioTransferStatus,
|
|
|
|
getBreakoutAudioTransferStatus,
|
2018-10-24 01:18:09 +08:00
|
|
|
};
|
|
|
|
})(BreakoutContainer);
|