2023-11-30 21:24:25 +08:00
|
|
|
import React from 'react';
|
2019-06-13 02:03:23 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2021-10-20 04:35:39 +08:00
|
|
|
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';
|
2024-01-12 00:32:32 +08:00
|
|
|
import { useMutation } from '@apollo/client';
|
2019-06-13 02:03:23 +08:00
|
|
|
import ManyUsersComponent from './component';
|
2023-11-30 21:24:25 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-01-12 00:32:32 +08:00
|
|
|
import { SET_WEBCAM_ONLY_FOR_MODERATOR } from '/imports/ui/components/lock-viewers/mutations';
|
2019-06-13 02:03:23 +08:00
|
|
|
|
2019-06-29 02:50:57 +08:00
|
|
|
const USER_CONFIG = Meteor.settings.public.user;
|
|
|
|
const ROLE_VIEWER = USER_CONFIG.role_viewer;
|
|
|
|
|
2023-11-30 21:24:25 +08:00
|
|
|
const ManyUsersContainer = (props) => {
|
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
isModerator: user.isModerator,
|
|
|
|
}));
|
|
|
|
|
2024-01-12 00:32:32 +08:00
|
|
|
const [setWebcamOnlyForModerator] = useMutation(SET_WEBCAM_ONLY_FOR_MODERATOR);
|
|
|
|
|
|
|
|
const toggleWebcamsOnlyForModerator = () => {
|
|
|
|
setWebcamOnlyForModerator({
|
|
|
|
variables: {
|
|
|
|
webcamsOnlyForModerator: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-11-30 21:24:25 +08:00
|
|
|
const currentUserIsModerator = currentUserData?.isModerator;
|
2024-01-12 00:32:32 +08:00
|
|
|
return <ManyUsersComponent {...{ toggleWebcamsOnlyForModerator, currentUserIsModerator, ...props }} />;
|
2023-11-30 21:24:25 +08:00
|
|
|
};
|
|
|
|
|
2019-09-06 02:29:30 +08:00
|
|
|
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);
|
2019-09-06 02:29:30 +08:00
|
|
|
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,
|
2019-09-06 02:29:30 +08:00
|
|
|
limitOfViewersInWebcam: Meteor.settings.public.app.viewersInWebcam,
|
|
|
|
limitOfViewersInWebcamIsEnable: Meteor.settings.public.app.enableLimitOfViewersInWebcam,
|
|
|
|
};
|
2023-11-30 21:24:25 +08:00
|
|
|
})(ManyUsersContainer);
|