Add context to manage locksettings
This commit is contained in:
parent
2d991cb078
commit
6a4103c559
@ -3,6 +3,7 @@ import { withTracker } from 'meteor/react-meteor-data';
|
||||
import { withModalMounter } from '/imports/ui/components/modal/service';
|
||||
import AudioManager from '/imports/ui/services/audio-manager';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
|
||||
import AudioControls from './component';
|
||||
import AudioModalContainer from '../audio-modal/container';
|
||||
import Service from '../service';
|
||||
@ -31,9 +32,9 @@ const processToggleMuteFromOutside = (e) => {
|
||||
}
|
||||
};
|
||||
|
||||
export default withModalMounter(withTracker(({ mountModal }) => ({
|
||||
export default lockContextContainer(withModalMounter(withTracker(({ mountModal, userLocks }) => ({
|
||||
processToggleMuteFromOutside: arg => processToggleMuteFromOutside(arg),
|
||||
showMute: Service.isConnected() && !Service.isListenOnly() && !Service.isEchoTest() && !Service.audioLocked(),
|
||||
showMute: Service.isConnected() && !Service.isListenOnly() && !Service.isEchoTest() && !userLocks.userMic,
|
||||
muted: Service.isConnected() && !Service.isListenOnly() && Service.isMuted(),
|
||||
inAudio: Service.isConnected() && !Service.isEchoTest(),
|
||||
listenOnly: Service.isConnected() && Service.isListenOnly(),
|
||||
@ -43,4 +44,4 @@ export default withModalMounter(withTracker(({ mountModal }) => ({
|
||||
handleToggleMuteMicrophone: () => Service.toggleMuteMicrophone(),
|
||||
handleJoinAudio: () => (Service.isConnected() ? Service.joinListenOnly() : mountModal(<AudioModalContainer />)),
|
||||
handleLeaveAudio: () => Service.exitAudio(),
|
||||
}))(AudioControlsContainer));
|
||||
}))(AudioControlsContainer)));
|
||||
|
@ -6,6 +6,7 @@ import getFromUserSettings from '/imports/ui/services/users-settings';
|
||||
import AudioModal from './component';
|
||||
import Meetings from '/imports/api/meetings';
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
|
||||
import Service from '../service';
|
||||
|
||||
const AudioModalContainer = props => <AudioModal {...props} />;
|
||||
@ -13,7 +14,7 @@ const AudioModalContainer = props => <AudioModal {...props} />;
|
||||
const APP_CONFIG = Meteor.settings.public.app;
|
||||
|
||||
|
||||
export default withModalMounter(withTracker(({ mountModal }) => {
|
||||
export default lockContextContainer(withModalMounter(withTracker(({ mountModal, userLocks }) => {
|
||||
const listenOnlyMode = getFromUserSettings('listenOnlyMode', APP_CONFIG.listenOnlyMode);
|
||||
const forceListenOnly = getFromUserSettings('forceListenOnly', APP_CONFIG.forceListenOnly);
|
||||
const skipCheck = getFromUserSettings('skipCheck', APP_CONFIG.skipCheck);
|
||||
@ -75,7 +76,7 @@ export default withModalMounter(withTracker(({ mountModal }) => {
|
||||
formattedDialNum,
|
||||
formattedTelVoice,
|
||||
combinedDialInNum,
|
||||
audioLocked: Service.audioLocked(),
|
||||
audioLocked: userLocks.userMic,
|
||||
joinFullAudioImmediately: !listenOnlyMode && skipCheck,
|
||||
joinFullAudioEchoTest: !listenOnlyMode && !skipCheck,
|
||||
forceListenOnlyAttendee: listenOnlyMode && forceListenOnly && !Service.isUserModerator(),
|
||||
@ -83,4 +84,4 @@ export default withModalMounter(withTracker(({ mountModal }) => {
|
||||
isMobileNative: navigator.userAgent.toLowerCase().includes('bbbnative'),
|
||||
isIEOrEdge: browser().name === 'edge' || browser().name === 'ie',
|
||||
});
|
||||
})(AudioModalContainer));
|
||||
})(AudioModalContainer)));
|
||||
|
@ -8,6 +8,7 @@ import Breakouts from '/imports/api/breakouts';
|
||||
import { notify } from '/imports/ui/services/notification';
|
||||
import getFromUserSettings from '/imports/ui/services/users-settings';
|
||||
import VideoPreviewContainer from '/imports/ui/components/video-preview/container';
|
||||
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
|
||||
import Service from './service';
|
||||
import AudioModalContainer from './audio-modal/container';
|
||||
|
||||
@ -73,19 +74,20 @@ class AudioContainer extends React.Component {
|
||||
|
||||
let didMountAutoJoin = false;
|
||||
|
||||
export default withModalMounter(injectIntl(withTracker(({ mountModal, intl }) => {
|
||||
export default lockContextContainer(withModalMounter(injectIntl(withTracker(({ mountModal, intl, userLocks }) => {
|
||||
const APP_CONFIG = Meteor.settings.public.app;
|
||||
const KURENTO_CONFIG = Meteor.settings.public.kurento;
|
||||
|
||||
const autoJoin = getFromUserSettings('autoJoin', APP_CONFIG.autoJoin);
|
||||
const { userWebcam } = userLocks;
|
||||
const openAudioModal = () => new Promise((resolve) => {
|
||||
mountModal(<AudioModalContainer resolve={resolve} />);
|
||||
});
|
||||
|
||||
const openVideoPreviewModal = () => new Promise((resolve) => {
|
||||
if (userWebcam) return resolve();
|
||||
mountModal(<VideoPreviewContainer resolve={resolve} />);
|
||||
});
|
||||
if (Service.audioLocked()
|
||||
if (userWebcam
|
||||
&& Service.isConnected()
|
||||
&& !Service.isListenOnly()
|
||||
&& !Service.isMuted()) {
|
||||
@ -144,4 +146,4 @@ export default withModalMounter(injectIntl(withTracker(({ mountModal, intl }) =>
|
||||
}
|
||||
},
|
||||
};
|
||||
})(AudioContainer)));
|
||||
})(AudioContainer))));
|
||||
|
@ -30,17 +30,6 @@ const init = (messages, intl) => {
|
||||
AudioManager.init(userData);
|
||||
};
|
||||
|
||||
const audioLocked = () => {
|
||||
const userId = Auth.userID;
|
||||
const User = mapUser(Users.findOne({ userId }));
|
||||
|
||||
const Meeting = Meetings.findOne({ meetingId: Auth.meetingID });
|
||||
const lockSetting = Meeting.lockSettingsProps;
|
||||
const audioLock = lockSetting ? lockSetting.disableMic : false;
|
||||
|
||||
return audioLock && User.isLocked;
|
||||
};
|
||||
|
||||
const currentUser = () => mapUser(Users.findOne({ intId: Auth.userID }));
|
||||
|
||||
export default {
|
||||
@ -66,6 +55,5 @@ export default {
|
||||
isEchoTest: () => AudioManager.isEchoTest,
|
||||
error: () => AudioManager.error,
|
||||
isUserModerator: () => Users.findOne({ userId: Auth.userID }).moderator,
|
||||
audioLocked,
|
||||
currentUser,
|
||||
};
|
||||
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import lockContext from './context';
|
||||
|
||||
|
||||
const contextProvider = Component => props => (
|
||||
<lockContext.Consumer>
|
||||
{ contexts => <Component {...props} {...contexts} />}
|
||||
</lockContext.Consumer>
|
||||
);
|
||||
|
||||
export default contextProvider;
|
@ -0,0 +1,34 @@
|
||||
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 mapUser from '/imports/ui/services/user/mapUser';
|
||||
import { DataStruct } from './context';
|
||||
import { withLockContext } from './withContext';
|
||||
|
||||
|
||||
const lockContextContainer = component => withTracker(() => {
|
||||
const lockSetting = new DataStruct();
|
||||
const Meeting = Meetings.findOne({ meetingId: Auth.meetingID });
|
||||
const User = Users.findOne({ userId: Auth.userID });
|
||||
const mappedUser = mapUser(User);
|
||||
const userIsLocked = mappedUser.isLocked;
|
||||
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.userLockOnJoin = userIsLocked && lockSettings.lockOnJoin;
|
||||
lockSetting.userLocks.userLockedLayout = userIsLocked && lockSettings.lockedLayout;
|
||||
lockSetting.userLocks.userOnJoinConfigurable = userIsLocked
|
||||
&& lockSettings.lockOnJoinConfigurable;
|
||||
|
||||
return lockSetting;
|
||||
})(withLockContext(component));
|
||||
|
||||
export default lockContextContainer;
|
@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
|
||||
export function DataStruct() {
|
||||
return ({
|
||||
isLocked: false,
|
||||
lockSettings: {
|
||||
disableCam: false,
|
||||
disableMic: false,
|
||||
disableNote: false,
|
||||
disablePrivateChat: false,
|
||||
disablePublicChat: false,
|
||||
lockOnJoin: true,
|
||||
lockOnJoinConfigurable: false,
|
||||
lockedLayout: false,
|
||||
},
|
||||
userLocks: {
|
||||
userWebcam: false,
|
||||
userMic: false,
|
||||
userNote: false,
|
||||
userPrivateChat: false,
|
||||
userPublicChat: false,
|
||||
userLockOnJoin: false,
|
||||
userOnJoinConfigurable: false,
|
||||
userLockedLayout: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const lockContext = React.createContext(new DataStruct());
|
||||
|
||||
export default lockContext;
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import lockContext from './context';
|
||||
|
||||
|
||||
const contextProvider = props => (
|
||||
<lockContext.Provider value={props}>
|
||||
{ props.children }
|
||||
</lockContext.Provider>
|
||||
);
|
||||
|
||||
export default contextProvider;
|
@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import LockProvider from './provider';
|
||||
import LockConsumer from './consumer';
|
||||
|
||||
const withProvider = Component => props => (
|
||||
<LockProvider {...props}>
|
||||
<Component />
|
||||
</LockProvider>
|
||||
);
|
||||
|
||||
const withConsumer = Component => LockConsumer(Component);
|
||||
|
||||
const withLockContext = Component => withProvider(withConsumer(Component));
|
||||
|
||||
export {
|
||||
withProvider,
|
||||
withConsumer,
|
||||
withLockContext,
|
||||
};
|
Loading…
Reference in New Issue
Block a user