2020-08-29 01:23:27 +08:00
|
|
|
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} />;
|
|
|
|
|
2020-09-26 03:41:30 +08:00
|
|
|
export default withModalMounter(withTracker(({ mountModal }) => {
|
|
|
|
const viewerPool = Users.find({
|
2020-08-29 01:23:27 +08:00
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
presenter: { $ne: true },
|
|
|
|
role: { $eq: 'VIEWER' },
|
|
|
|
}, {
|
|
|
|
fields: {
|
|
|
|
userId: 1,
|
|
|
|
},
|
|
|
|
}).fetch();
|
|
|
|
|
2020-09-26 03:41:30 +08:00
|
|
|
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }, {
|
|
|
|
fields: {
|
|
|
|
randomlySelectedUser: 1,
|
|
|
|
},
|
|
|
|
});
|
2020-08-29 01:23:27 +08:00
|
|
|
|
2020-09-26 03:41:30 +08:00
|
|
|
const selectedUser = Users.findOne({
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
userId: meeting.randomlySelectedUser,
|
|
|
|
}, {
|
|
|
|
fields: {
|
|
|
|
userId: 1,
|
|
|
|
avatar: 1,
|
|
|
|
color: 1,
|
|
|
|
name: 1,
|
|
|
|
},
|
|
|
|
});
|
2020-08-29 01:23:27 +08:00
|
|
|
|
2020-09-26 03:41:30 +08:00
|
|
|
const currentUser = Users.findOne(
|
|
|
|
{ userId: Auth.userID },
|
|
|
|
{ fields: { userId: 1, presenter: 1 } },
|
|
|
|
);
|
2020-08-29 01:23:27 +08:00
|
|
|
|
2020-09-26 03:41:30 +08:00
|
|
|
const randomUserReq = () => makeCall('setRandomUser');
|
2020-08-29 01:23:27 +08:00
|
|
|
|
2020-10-19 22:46:41 +08:00
|
|
|
const clearRandomlySelectedUser = () => makeCall('clearRandomlySelectedUser');
|
|
|
|
|
2020-08-29 01:23:27 +08:00
|
|
|
return ({
|
|
|
|
closeModal: () => mountModal(null),
|
2020-09-26 03:41:30 +08:00
|
|
|
numAvailableViewers: viewerPool.length,
|
|
|
|
randomUserReq,
|
|
|
|
selectedUser,
|
|
|
|
currentUser,
|
2020-10-19 22:46:41 +08:00
|
|
|
clearRandomlySelectedUser,
|
2020-08-29 01:23:27 +08:00
|
|
|
});
|
|
|
|
})(RandomUserSelectContainer));
|