bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/modal/random-user/container.jsx
2020-09-25 19:41:30 +00:00

57 lines
1.4 KiB
JavaScript

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import Meetings from '/imports/api/meetings';
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import { withModalMounter } from '/imports/ui/components/modal/service';
import { makeCall } from '/imports/ui/services/api';
import RandomUserSelect from './component';
const RandomUserSelectContainer = props => <RandomUserSelect {...props} />;
export default withModalMounter(withTracker(({ mountModal }) => {
const viewerPool = Users.find({
meetingId: Auth.meetingID,
presenter: { $ne: true },
connectionStatus: 'online',
role: { $eq: 'VIEWER' },
}, {
fields: {
userId: 1,
},
}).fetch();
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }, {
fields: {
randomlySelectedUser: 1,
},
});
const selectedUser = Users.findOne({
meetingId: Auth.meetingID,
userId: meeting.randomlySelectedUser,
}, {
fields: {
userId: 1,
avatar: 1,
color: 1,
name: 1,
},
});
const currentUser = Users.findOne(
{ userId: Auth.userID },
{ fields: { userId: 1, presenter: 1 } },
);
const randomUserReq = () => makeCall('setRandomUser');
return ({
closeModal: () => mountModal(null),
numAvailableViewers: viewerPool.length,
randomUserReq,
selectedUser,
currentUser,
});
})(RandomUserSelectContainer));