From f6609524eaae5f380bc9219ad9faef90812a1273 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 2 Nov 2016 16:14:36 -0500 Subject: [PATCH] Disables loading side panels when they are disabled. Adds some safety checks for disabled contactlist. --- conference.js | 3 ++- modules/UI/UI.js | 15 ++++++++++----- modules/UI/side_pannels/SidePanels.js | 13 +++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/conference.js b/conference.js index 5dd771f5b..03a9140cb 100644 --- a/conference.js +++ b/conference.js @@ -514,7 +514,8 @@ export default { this.isDesktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled(); - APP.UI.ContactList = new ContactList(room); + if (UIUtil.isButtonEnabled('contacts')) + APP.UI.ContactList = new ContactList(room); // if user didn't give access to mic or camera or doesn't have // them at all, we disable corresponding toolbar buttons diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 3f4cd3305..021a41862 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -203,7 +203,8 @@ UI.showChatError = function (err, msg) { * @param {string} displayName new nickname */ UI.changeDisplayName = function (id, displayName) { - UI.ContactList.onDisplayNameChange(id, displayName); + if (UI.ContactList) + UI.ContactList.onDisplayNameChange(id, displayName); VideoLayout.onDisplayNameChanged(id, displayName); if (APP.conference.isLocalId(id) || id === 'localVideoContainer') { @@ -249,7 +250,8 @@ UI.setLocalRaisedHandStatus = (raisedHandStatus) => { UI.initConference = function () { let id = APP.conference.getMyUserId(); // Add myself to the contact list. - UI.ContactList.addContact(id, true); + if (UI.ContactList) + UI.ContactList.addContact(id, true); // Update default button states before showing the toolbar // if local role changes buttons state will be again updated. @@ -559,7 +561,8 @@ UI.addUser = function (user) { var id = user.getId(); var displayName = user.getDisplayName(); UI.hideRingOverLay(); - UI.ContactList.addContact(id); + if (UI.ContactList) + UI.ContactList.addContact(id); messageHandler.notify( displayName,'notify.somebody', 'connected', 'notify.connected' @@ -586,7 +589,8 @@ UI.addUser = function (user) { * @param {string} displayName user nickname */ UI.removeUser = function (id, displayName) { - UI.ContactList.removeContact(id); + if (UI.ContactList) + UI.ContactList.removeContact(id); messageHandler.notify( displayName,'notify.somebody', 'disconnected', 'notify.disconnected' @@ -838,7 +842,8 @@ UI.dockToolbar = function (isDock) { */ function changeAvatar(id, avatarUrl) { VideoLayout.changeUserAvatar(id, avatarUrl); - UI.ContactList.changeUserAvatar(id, avatarUrl); + if (UI.ContactList) + UI.ContactList.changeUserAvatar(id, avatarUrl); if (APP.conference.isLocalId(id)) { Profile.changeAvatar(avatarUrl); } diff --git a/modules/UI/side_pannels/SidePanels.js b/modules/UI/side_pannels/SidePanels.js index cb50ea376..e0808fcd2 100644 --- a/modules/UI/side_pannels/SidePanels.js +++ b/modules/UI/side_pannels/SidePanels.js @@ -2,17 +2,22 @@ import Chat from './chat/Chat'; import SettingsMenu from './settings/SettingsMenu'; import Profile from './profile/Profile'; import ContactListView from './contactlist/ContactListView'; +import UIUtil from '../util/UIUtil'; const SidePanels = { init (eventEmitter) { //Initialize chat - Chat.init(eventEmitter); + if (UIUtil.isButtonEnabled('chat')) + Chat.init(eventEmitter); //Initialize settings - SettingsMenu.init(eventEmitter); + if (UIUtil.isButtonEnabled('settings')) + SettingsMenu.init(eventEmitter); //Initialize profile - Profile.init(eventEmitter); + if (UIUtil.isButtonEnabled('profile')) + Profile.init(eventEmitter); //Initialize contact list view - ContactListView.init(); + if (UIUtil.isButtonEnabled('contacts')) + ContactListView.init(); } };