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

53 lines
1.8 KiB
React
Raw Normal View History

import React from 'react';
2018-07-07 01:38:14 +08:00
import { withTracker } from 'meteor/react-meteor-data';
import Breakouts from '/imports/api/breakouts';
2018-07-07 01:38:14 +08:00
import Auth from '/imports/ui/services/auth';
2024-01-16 19:39:13 +08:00
import { useMutation } from '@apollo/client';
import breakoutService from '/imports/ui/components/breakout-room/service';
2019-07-26 22:35:20 +08:00
import AudioManager from '/imports/ui/services/audio-manager';
2018-07-07 01:38:14 +08:00
import BreakoutJoinConfirmationComponent from './component';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
2024-01-16 19:39:13 +08:00
import { BREAKOUT_ROOM_REQUEST_JOIN_URL } from '../breakout-room/mutations';
2018-07-07 01:38:14 +08:00
2021-11-24 00:41:37 +08:00
const BreakoutJoinConfirmationContrainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
}));
const amIPresenter = currentUserData?.presenter;
2021-11-24 00:41:37 +08:00
2024-01-16 19:39:13 +08:00
const [breakoutRoomRequestJoinURL] = useMutation(BREAKOUT_ROOM_REQUEST_JOIN_URL);
const requestJoinURL = (breakoutRoomId) => {
breakoutRoomRequestJoinURL({ variables: { breakoutRoomId } });
};
2021-11-24 00:41:37 +08:00
return <BreakoutJoinConfirmationComponent
{...props}
2021-11-24 00:41:37 +08:00
amIPresenter={amIPresenter}
2024-01-16 19:39:13 +08:00
requestJoinURL={requestJoinURL}
/>
2021-11-24 00:41:37 +08:00
};
2018-07-07 01:38:14 +08:00
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;
2018-07-07 01:38:14 +08:00
return '';
};
export default withTracker(({ breakout, breakoutName }) => {
2018-07-07 01:38:14 +08:00
const isFreeJoin = breakout.freeJoin;
const { breakoutId } = breakout;
const url = getURL(breakoutId);
return {
isFreeJoin,
breakoutName,
breakoutURL: url,
breakouts: breakoutService.getBreakouts(),
2018-07-07 01:38:14 +08:00
getURL,
2019-07-26 22:35:20 +08:00
voiceUserJoined: AudioManager.isUsingAudio(),
2018-07-07 01:38:14 +08:00
};
})(BreakoutJoinConfirmationContrainer);