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';
|
2021-04-07 03:58:11 +08:00
|
|
|
import { withUsersConsumer } from '/imports/ui/components/components-data/users-context/context';
|
2019-05-24 00:47:56 +08:00
|
|
|
import { withLockContext } from './withContext';
|
|
|
|
|
2019-07-31 04:00:38 +08:00
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
2019-05-24 00:47:56 +08:00
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
const lockContextContainer = component => withUsersConsumer(withTracker(({ users }) => {
|
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 },
|
|
|
|
{ fields: { lockSettingsProps: 1 } });
|
2021-04-15 20:12:21 +08:00
|
|
|
const User = users[Auth.meetingID][Auth.userID];
|
2019-08-24 01:25:33 +08:00
|
|
|
const userIsLocked = User.locked && User.role !== ROLE_MODERATOR;
|
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.userNote = userIsLocked && lockSettings.disableNote;
|
|
|
|
lockSetting.userLocks.userPrivateChat = userIsLocked && lockSettings.disablePrivateChat;
|
|
|
|
lockSetting.userLocks.userPublicChat = userIsLocked && lockSettings.disablePublicChat;
|
|
|
|
lockSetting.userLocks.userLockedLayout = userIsLocked && lockSettings.lockedLayout;
|
|
|
|
|
|
|
|
return lockSetting;
|
2021-04-07 03:58:11 +08:00
|
|
|
})(withLockContext(component)));
|
2019-05-24 00:47:56 +08:00
|
|
|
|
|
|
|
export default lockContextContainer;
|