bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx

32 lines
1.5 KiB
React
Raw Normal View History

2019-05-24 00:47:56 +08:00
import { withTracker } from 'meteor/react-meteor-data';
import Meetings from '/imports/api/meetings';
2019-05-24 00:47:56 +08:00
import Auth from '/imports/ui/services/auth';
import { LockStruct } from './context';
2022-02-24 03:33:35 +08:00
import Users from '/imports/api/users';
2019-05-24 00:47:56 +08:00
import { withLockContext } from './withContext';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
2019-05-24 00:47:56 +08:00
2022-02-24 03:33:35 +08:00
const lockContextContainer = (component) => withTracker(() => {
const lockSetting = new LockStruct();
const Meeting = Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { lockSettingsProps: 1 } });
2022-02-24 03:33:35 +08:00
const User = Users.findOne({ userId: Auth.userID, meetingId: Auth.meetingID },
{ fields: { role: 1, locked: 1 } });
2022-05-03 04:22:02 +08:00
const userIsLocked = User ? User.locked && User.role !== ROLE_MODERATOR : true;
2019-05-24 00:47:56 +08:00
const lockSettings = Meeting.lockSettingsProps;
lockSetting.isLocked = userIsLocked;
lockSetting.lockSettings = lockSettings;
lockSetting.userLocks.userWebcam = userIsLocked && lockSettings.disableCam;
lockSetting.userLocks.userMic = userIsLocked && lockSettings.disableMic;
lockSetting.userLocks.userNotes = userIsLocked && lockSettings.disableNotes;
2019-05-24 00:47:56 +08:00
lockSetting.userLocks.userPrivateChat = userIsLocked && lockSettings.disablePrivateChat;
lockSetting.userLocks.userPublicChat = userIsLocked && lockSettings.disablePublicChat;
lockSetting.userLocks.hideViewersCursor = userIsLocked && lockSettings.hideViewersCursor;
2019-05-24 00:47:56 +08:00
return lockSetting;
2022-02-24 03:33:35 +08:00
})(withLockContext(component));
2019-05-24 00:47:56 +08:00
export default lockContextContainer;