bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/lock-viewers/container.jsx
2024-05-20 08:56:15 -03:00

62 lines
2.0 KiB
JavaScript
Executable File

import React from 'react';
import { useMutation } from '@apollo/client';
import LockViewersComponent from './component';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import { SET_LOCK_SETTINGS_PROPS, SET_WEBCAM_ONLY_FOR_MODERATOR } from './mutations';
import useMeeting from '../../core/hooks/useMeeting';
const LockViewersContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
isModerator: user.isModerator,
}));
const amIModerator = currentUserData?.isModerator;
const [setLockSettingsProps] = useMutation(SET_LOCK_SETTINGS_PROPS);
const [setWebcamOnlyForModerator] = useMutation(SET_WEBCAM_ONLY_FOR_MODERATOR);
const updateLockSettings = (lockSettings) => {
setLockSettingsProps({
variables: {
disableCam: lockSettings.disableCam,
disableMic: lockSettings.disableMic,
disablePrivChat: lockSettings.disablePrivateChat,
disablePubChat: lockSettings.disablePublicChat,
disableNotes: lockSettings.disableNotes,
hideUserList: lockSettings.hideUserList,
lockOnJoin: lockSettings.lockOnJoin,
lockOnJoinConfigurable: lockSettings.lockOnJoinConfigurable,
hideViewersCursor: lockSettings.hideViewersCursor,
hideViewersAnnotation: lockSettings.hideViewersAnnotation,
},
});
};
const updateWebcamsOnlyForModerator = (webcamsOnlyForModerator) => {
setWebcamOnlyForModerator({
variables: {
webcamsOnlyForModerator,
},
});
};
const { setIsOpen } = props;
const closeModal = () => setIsOpen(false);
const { data: meeting } = useMeeting((m) => ({
lockSettings: m.lockSettings,
usersPolicies: m.usersPolicies,
}));
return amIModerator && meeting && (
<LockViewersComponent
updateWebcamsOnlyForModerator={updateWebcamsOnlyForModerator}
updateLockSettings={updateLockSettings}
closeModal={closeModal}
showToggleLabel={false}
meeting={meeting}
{...props}
/>
);
};
export default LockViewersContainer;