From 6a4103c559ebaa64e56a64b0be6ca345540669df Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Thu, 23 May 2019 13:47:56 -0300 Subject: [PATCH 1/5] Add context to manage locksettings --- .../audio/audio-controls/container.jsx | 7 ++-- .../audio/audio-modal/container.jsx | 7 ++-- .../imports/ui/components/audio/container.jsx | 10 +++--- .../imports/ui/components/audio/service.js | 12 ------- .../lock-viewers/context/consumer.jsx | 11 ++++++ .../lock-viewers/context/container.jsx | 34 +++++++++++++++++++ .../lock-viewers/context/context.js | 31 +++++++++++++++++ .../lock-viewers/context/provider.jsx | 11 ++++++ .../lock-viewers/context/withContext.jsx | 19 +++++++++++ 9 files changed, 120 insertions(+), 22 deletions(-) create mode 100644 bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx create mode 100644 bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx create mode 100644 bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js create mode 100644 bigbluebutton-html5/imports/ui/components/lock-viewers/context/provider.jsx create mode 100644 bigbluebutton-html5/imports/ui/components/lock-viewers/context/withContext.jsx diff --git a/bigbluebutton-html5/imports/ui/components/audio/audio-controls/container.jsx b/bigbluebutton-html5/imports/ui/components/audio/audio-controls/container.jsx index aa795e0ffd..f8c39cb262 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/audio-controls/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/audio-controls/container.jsx @@ -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()), handleLeaveAudio: () => Service.exitAudio(), -}))(AudioControlsContainer)); +}))(AudioControlsContainer))); diff --git a/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx b/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx index 3a46ab356d..f43cae3aa6 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx @@ -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 => ; @@ -13,7 +14,7 @@ const AudioModalContainer = 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))); diff --git a/bigbluebutton-html5/imports/ui/components/audio/container.jsx b/bigbluebutton-html5/imports/ui/components/audio/container.jsx index 7ef508254e..9afc71696a 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/container.jsx @@ -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(); }); const openVideoPreviewModal = () => new Promise((resolve) => { + if (userWebcam) return resolve(); mountModal(); }); - if (Service.audioLocked() + if (userWebcam && Service.isConnected() && !Service.isListenOnly() && !Service.isMuted()) { @@ -144,4 +146,4 @@ export default withModalMounter(injectIntl(withTracker(({ mountModal, intl }) => } }, }; -})(AudioContainer))); +})(AudioContainer)))); diff --git a/bigbluebutton-html5/imports/ui/components/audio/service.js b/bigbluebutton-html5/imports/ui/components/audio/service.js index 3c60c2d6e9..949bc6548c 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/service.js +++ b/bigbluebutton-html5/imports/ui/components/audio/service.js @@ -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, }; diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx new file mode 100644 index 0000000000..35879dacf7 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx @@ -0,0 +1,11 @@ +import React from 'react'; +import lockContext from './context'; + + +const contextProvider = Component => props => ( + + { contexts => } + +); + +export default contextProvider; diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx new file mode 100644 index 0000000000..9ac26e0ab7 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx @@ -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; diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js new file mode 100644 index 0000000000..8d22e122c5 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js @@ -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; diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/provider.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/provider.jsx new file mode 100644 index 0000000000..0a681c0287 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/provider.jsx @@ -0,0 +1,11 @@ +import React from 'react'; +import lockContext from './context'; + + +const contextProvider = props => ( + + { props.children } + +); + +export default contextProvider; diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/withContext.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/withContext.jsx new file mode 100644 index 0000000000..6d230d8e91 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/withContext.jsx @@ -0,0 +1,19 @@ +import React from 'react'; +import LockProvider from './provider'; +import LockConsumer from './consumer'; + +const withProvider = Component => props => ( + + + +); + +const withConsumer = Component => LockConsumer(Component); + +const withLockContext = Component => withProvider(withConsumer(Component)); + +export { + withProvider, + withConsumer, + withLockContext, +}; From d77ebaf90b0facee36e85526532dc36e540e96c0 Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Fri, 24 May 2019 15:09:09 -0300 Subject: [PATCH 2/5] Fix misspelling in consumer --- .../imports/ui/components/lock-viewers/context/consumer.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx index 35879dacf7..82769e2cc5 100644 --- a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/consumer.jsx @@ -2,10 +2,10 @@ import React from 'react'; import lockContext from './context'; -const contextProvider = Component => props => ( +const contextConsumer = Component => props => ( { contexts => } ); -export default contextProvider; +export default contextConsumer; From 747afb30932345ab1f93683b1a7309739e9fe868 Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Tue, 11 Jun 2019 15:04:47 -0300 Subject: [PATCH 3/5] Fix misscomparation --- bigbluebutton-html5/imports/ui/components/audio/container.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/audio/container.jsx b/bigbluebutton-html5/imports/ui/components/audio/container.jsx index 9afc71696a..498f7ef642 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/container.jsx @@ -78,7 +78,7 @@ export default lockContextContainer(withModalMounter(injectIntl(withTracker(({ m 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 { userWebcam, userMic } = userLocks; const openAudioModal = () => new Promise((resolve) => { mountModal(); }); @@ -87,7 +87,7 @@ export default lockContextContainer(withModalMounter(injectIntl(withTracker(({ m if (userWebcam) return resolve(); mountModal(); }); - if (userWebcam + if (userMic && Service.isConnected() && !Service.isListenOnly() && !Service.isMuted()) { From 8f619802edc3cdc3d1bf4280d1c1e608136e423c Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Tue, 11 Jun 2019 15:23:27 -0300 Subject: [PATCH 4/5] Rename structure and remove some fields --- .../ui/components/lock-viewers/context/container.jsx | 7 ++----- .../imports/ui/components/lock-viewers/context/context.js | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx index 9ac26e0ab7..192a446820 100644 --- a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/container.jsx @@ -4,12 +4,12 @@ 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 { LockStruct } from './context'; import { withLockContext } from './withContext'; const lockContextContainer = component => withTracker(() => { - const lockSetting = new DataStruct(); + const lockSetting = new LockStruct(); const Meeting = Meetings.findOne({ meetingId: Auth.meetingID }); const User = Users.findOne({ userId: Auth.userID }); const mappedUser = mapUser(User); @@ -23,10 +23,7 @@ const lockContextContainer = component => withTracker(() => { 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)); diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js index 8d22e122c5..7bf3e090ac 100644 --- a/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/context/context.js @@ -1,6 +1,6 @@ import React from 'react'; -export function DataStruct() { +export function LockStruct() { return ({ isLocked: false, lockSettings: { @@ -19,13 +19,11 @@ export function DataStruct() { userNote: false, userPrivateChat: false, userPublicChat: false, - userLockOnJoin: false, - userOnJoinConfigurable: false, userLockedLayout: false, }, }); } -const lockContext = React.createContext(new DataStruct()); +const lockContext = React.createContext(new LockStruct()); export default lockContext; From d9fb477c3a44f1469841988196a46fac755b4f0f Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Tue, 11 Jun 2019 16:35:07 -0300 Subject: [PATCH 5/5] Apply lock if viewer is presenter --- bigbluebutton-html5/imports/ui/services/user/mapUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigbluebutton-html5/imports/ui/services/user/mapUser.js b/bigbluebutton-html5/imports/ui/services/user/mapUser.js index 14b554e43f..6d4ac86ac9 100755 --- a/bigbluebutton-html5/imports/ui/services/user/mapUser.js +++ b/bigbluebutton-html5/imports/ui/services/user/mapUser.js @@ -34,7 +34,7 @@ const mapUser = (user) => { externalUserId: user.extId, }; - mappedUser.isLocked = user.locked && !(mappedUser.isPresenter || mappedUser.isModerator); + mappedUser.isLocked = user.locked && !mappedUser.isModerator; return mappedUser; };