bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/breakout-join-confirmation/container.jsx
2024-01-16 08:39:13 -03:00

53 lines
1.8 KiB
JavaScript
Executable File

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import Breakouts from '/imports/api/breakouts';
import Auth from '/imports/ui/services/auth';
import { useMutation } from '@apollo/client';
import breakoutService from '/imports/ui/components/breakout-room/service';
import AudioManager from '/imports/ui/services/audio-manager';
import BreakoutJoinConfirmationComponent from './component';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import { BREAKOUT_ROOM_REQUEST_JOIN_URL } from '../breakout-room/mutations';
const BreakoutJoinConfirmationContrainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
}));
const amIPresenter = currentUserData?.presenter;
const [breakoutRoomRequestJoinURL] = useMutation(BREAKOUT_ROOM_REQUEST_JOIN_URL);
const requestJoinURL = (breakoutRoomId) => {
breakoutRoomRequestJoinURL({ variables: { breakoutRoomId } });
};
return <BreakoutJoinConfirmationComponent
{...props}
amIPresenter={amIPresenter}
requestJoinURL={requestJoinURL}
/>
};
const getURL = (breakoutId) => {
const currentUserId = Auth.userID;
const breakout = Breakouts.findOne({ breakoutId }, { fields: { [`url_${currentUserId}`]: 1 } });
const breakoutUrlData = (breakout && breakout[`url_${currentUserId}`]) ? breakout[`url_${currentUserId}`] : null;
if (breakoutUrlData) return breakoutUrlData.redirectToHtml5JoinURL;
return '';
};
export default withTracker(({ breakout, breakoutName }) => {
const isFreeJoin = breakout.freeJoin;
const { breakoutId } = breakout;
const url = getURL(breakoutId);
return {
isFreeJoin,
breakoutName,
breakoutURL: url,
breakouts: breakoutService.getBreakouts(),
getURL,
voiceUserJoined: AudioManager.isUsingAudio(),
};
})(BreakoutJoinConfirmationContrainer);