bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-provider/many-users-notify/container.jsx

56 lines
2.0 KiB
React
Raw Normal View History

import React from 'react';
2019-06-13 02:03:23 +08:00
import { withTracker } from 'meteor/react-meteor-data';
import Meetings from '/imports/api/meetings';
2019-06-13 02:03:23 +08:00
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users/';
2019-09-07 00:50:31 +08:00
import VideoStreams from '/imports/api/video-streams';
import { useMutation } from '@apollo/client';
2019-06-13 02:03:23 +08:00
import ManyUsersComponent from './component';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import { SET_WEBCAM_ONLY_FOR_MODERATOR } from '/imports/ui/components/lock-viewers/mutations';
2019-06-13 02:03:23 +08:00
const USER_CONFIG = Meteor.settings.public.user;
const ROLE_VIEWER = USER_CONFIG.role_viewer;
const ManyUsersContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
isModerator: user.isModerator,
}));
const [setWebcamOnlyForModerator] = useMutation(SET_WEBCAM_ONLY_FOR_MODERATOR);
const toggleWebcamsOnlyForModerator = () => {
setWebcamOnlyForModerator({
variables: {
webcamsOnlyForModerator: true,
},
});
};
const currentUserIsModerator = currentUserData?.isModerator;
return <ManyUsersComponent {...{ toggleWebcamsOnlyForModerator, currentUserIsModerator, ...props }} />;
};
export default withTracker(() => {
2019-09-06 21:19:18 +08:00
const meeting = Meetings.findOne({
meetingId: Auth.meetingID,
}, { fields: { 'usersProp.webcamsOnlyForModerator': 1, lockSettingsProps: 1 } });
2019-09-07 00:50:31 +08:00
const videoStreams = VideoStreams.find({ meetingId: Auth.meetingID },
2019-09-06 04:03:22 +08:00
{ fields: { userId: 1 } }).fetch();
2019-09-07 00:50:31 +08:00
const videoUsersIds = videoStreams.map(u => u.userId);
return {
viewersInWebcam: Users.find({
meetingId: Auth.meetingID,
userId: {
$in: videoUsersIds,
},
role: ROLE_VIEWER,
presenter: false,
2019-09-06 04:03:22 +08:00
}, { fields: {} }).count(),
2019-09-10 03:30:14 +08:00
lockSettings: meeting.lockSettingsProps,
2019-09-05 02:32:58 +08:00
webcamOnlyForModerator: meeting.usersProp.webcamsOnlyForModerator,
limitOfViewersInWebcam: Meteor.settings.public.app.viewersInWebcam,
limitOfViewersInWebcamIsEnable: Meteor.settings.public.app.enableLimitOfViewersInWebcam,
};
})(ManyUsersContainer);