2019-05-24 00:47:56 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2021-10-20 04:35:39 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2019-05-24 00:47:56 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2019-06-12 02:23:27 +08:00
|
|
|
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';
|
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
const ROLE_MODERATOR = window.meetingClientSettings.public.user.role_moderator;
|
2019-05-24 00:47:56 +08:00
|
|
|
|
2022-02-24 03:33:35 +08:00
|
|
|
const lockContextContainer = (component) => withTracker(() => {
|
2019-06-12 02:23:27 +08:00
|
|
|
const lockSetting = new LockStruct();
|
2019-08-30 00:26:07 +08:00
|
|
|
const Meeting = Meetings.findOne({ meetingId: Auth.meetingID },
|
2024-03-26 19:57:28 +08:00
|
|
|
{ fields: { lockSettings: 1 } });
|
2024-03-13 01:37:28 +08:00
|
|
|
const User = Users.findOne({ userId: Auth.userID },
|
2022-02-24 03:33:35 +08:00
|
|
|
{ fields: { role: 1, locked: 1 } });
|
2022-05-03 04:22:02 +08:00
|
|
|
const userIsLocked = User ? User.locked && User.role !== ROLE_MODERATOR : true;
|
2024-03-26 19:57:28 +08:00
|
|
|
const lockSettings = Meeting.lockSettings;
|
2019-05-24 00:47:56 +08:00
|
|
|
|
|
|
|
lockSetting.isLocked = userIsLocked;
|
|
|
|
lockSetting.lockSettings = lockSettings;
|
|
|
|
lockSetting.userLocks.userWebcam = userIsLocked && lockSettings.disableCam;
|
|
|
|
lockSetting.userLocks.userMic = userIsLocked && lockSettings.disableMic;
|
2021-10-16 03:07:13 +08:00
|
|
|
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;
|
2022-03-24 02:55:19 +08:00
|
|
|
lockSetting.userLocks.hideViewersCursor = userIsLocked && lockSettings.hideViewersCursor;
|
2023-06-06 04:02:06 +08:00
|
|
|
lockSetting.userLocks.hideViewersAnnotation = userIsLocked && lockSettings.hideViewersAnnotation;
|
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;
|