2018-11-07 07:10:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2021-09-07 04:51:42 +08:00
|
|
|
import Users from '/imports/ui/local-collections/users-collection/users';
|
|
|
|
import Meetings from '/imports/ui/local-collections/meetings-collection/meetings';
|
2020-05-10 01:19:41 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2018-11-07 07:10:56 +08:00
|
|
|
import Service from './service';
|
|
|
|
import VideoPreview from './component';
|
2019-11-28 21:13:06 +08:00
|
|
|
import VideoService from '../video-provider/service';
|
2019-11-06 04:23:13 +08:00
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
const VideoPreviewContainer = props => <VideoPreview {...props} />;
|
|
|
|
|
2020-05-10 01:19:41 +08:00
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
|
|
|
|
|
|
|
const isCamLocked = () => {
|
|
|
|
const meeting = Meetings.findOne({ meetingId: Auth.meetingID },
|
|
|
|
{ fields: { 'lockSettingsProps.disableCam': 1 } });
|
|
|
|
const user = Users.findOne({ meetingId: Auth.meetingID, userId: Auth.userID },
|
|
|
|
{ fields: { locked: 1, role: 1 } });
|
|
|
|
|
|
|
|
if (meeting.lockSettingsProps !== undefined) {
|
|
|
|
if (user.locked && user.role !== ROLE_MODERATOR) {
|
|
|
|
return meeting.lockSettingsProps.disableCam;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2021-02-02 02:47:05 +08:00
|
|
|
export default withModalMounter(withTracker(({ mountModal }) => ({
|
2020-05-26 01:32:24 +08:00
|
|
|
startSharing: (deviceId) => {
|
2018-11-07 07:10:56 +08:00
|
|
|
mountModal(null);
|
2019-11-28 00:19:09 +08:00
|
|
|
VideoService.joinVideo(deviceId);
|
2018-11-07 07:10:56 +08:00
|
|
|
},
|
2020-05-26 01:32:24 +08:00
|
|
|
stopSharing: (deviceId) => {
|
2019-11-29 04:28:41 +08:00
|
|
|
mountModal(null);
|
2020-03-12 03:42:53 +08:00
|
|
|
if (deviceId) {
|
2021-04-03 11:06:39 +08:00
|
|
|
const streamId = VideoService.getMyStreamId(deviceId);
|
|
|
|
if (streamId) VideoService.stopVideo(streamId);
|
2020-03-12 03:42:53 +08:00
|
|
|
} else {
|
|
|
|
VideoService.exitVideo();
|
|
|
|
}
|
2019-11-29 04:28:41 +08:00
|
|
|
},
|
|
|
|
sharedDevices: VideoService.getSharedDevices(),
|
2020-05-10 01:19:41 +08:00
|
|
|
isCamLocked: isCamLocked(),
|
2019-06-28 00:02:42 +08:00
|
|
|
closeModal: () => mountModal(null),
|
2018-11-17 02:56:39 +08:00
|
|
|
webcamDeviceId: Service.webcamDeviceId(),
|
2020-03-12 03:42:53 +08:00
|
|
|
hasVideoStream: VideoService.hasVideoStream(),
|
2018-11-07 07:10:56 +08:00
|
|
|
}))(VideoPreviewContainer));
|