You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var UI = {};
  4. import Chat from "./side_pannels/chat/Chat";
  5. import SidePanels from "./side_pannels/SidePanels";
  6. import Avatar from "./avatar/Avatar";
  7. import SideContainerToggler from "./side_pannels/SideContainerToggler";
  8. import JitsiPopover from "./util/JitsiPopover";
  9. import messageHandler from "./util/MessageHandler";
  10. import UIUtil from "./util/UIUtil";
  11. import UIEvents from "../../service/UI/UIEvents";
  12. import EtherpadManager from './etherpad/Etherpad';
  13. import SharedVideoManager from './shared_video/SharedVideo';
  14. import Recording from "./recording/Recording";
  15. import VideoLayout from "./videolayout/VideoLayout";
  16. import Filmstrip from "./videolayout/Filmstrip";
  17. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  18. import Profile from "./side_pannels/profile/Profile";
  19. import Settings from "./../settings/Settings";
  20. import { FEEDBACK_REQUEST_IN_PROGRESS } from './UIErrors';
  21. import { debounce } from "../util/helpers";
  22. import { updateDeviceList } from '../../react/features/base/devices';
  23. import { setAudioMuted, setVideoMuted } from '../../react/features/base/media';
  24. import {
  25. openDeviceSelectionDialog
  26. } from '../../react/features/device-selection';
  27. import {
  28. checkAutoEnableDesktopSharing,
  29. dockToolbox,
  30. setToolbarButton,
  31. showDialPadButton,
  32. showEtherpadButton,
  33. showSharedVideoButton,
  34. showDialOutButton,
  35. showToolbox
  36. } from '../../react/features/toolbox';
  37. import {
  38. maybeShowNotificationWithDoNotDisplay,
  39. setNotificationsEnabled
  40. } from '../../react/features/notifications';
  41. var EventEmitter = require("events");
  42. UI.messageHandler = messageHandler;
  43. import Feedback from "./feedback/Feedback";
  44. import FollowMe from "../FollowMe";
  45. var eventEmitter = new EventEmitter();
  46. UI.eventEmitter = eventEmitter;
  47. let etherpadManager;
  48. let sharedVideoManager;
  49. let followMeHandler;
  50. const TrackErrors = JitsiMeetJS.errors.track;
  51. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  52. microphone: {},
  53. camera: {}
  54. };
  55. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  56. = "dialog.cameraUnsupportedResolutionError";
  57. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  58. = "dialog.cameraUnknownError";
  59. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  60. = "dialog.cameraPermissionDeniedError";
  61. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  62. = "dialog.cameraNotFoundError";
  63. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  64. = "dialog.cameraConstraintFailedError";
  65. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  66. = "dialog.cameraNotSendingData";
  67. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  68. = "dialog.micUnknownError";
  69. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  70. = "dialog.micPermissionDeniedError";
  71. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  72. = "dialog.micNotFoundError";
  73. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  74. = "dialog.micConstraintFailedError";
  75. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  76. = "dialog.micNotSendingData";
  77. /**
  78. * Toggles the application in and out of full screen mode
  79. * (a.k.a. presentation mode in Chrome).
  80. */
  81. UI.toggleFullScreen = function() {
  82. (UIUtil.isFullScreen())
  83. ? UIUtil.exitFullScreen()
  84. : UIUtil.enterFullScreen();
  85. };
  86. /**
  87. * Notify user that server has shut down.
  88. */
  89. UI.notifyGracefulShutdown = function () {
  90. messageHandler.openMessageDialog(
  91. 'dialog.serviceUnavailable',
  92. 'dialog.gracefulShutdown'
  93. );
  94. };
  95. /**
  96. * Notify user that reservation error happened.
  97. */
  98. UI.notifyReservationError = function (code, msg) {
  99. var message = APP.translation.generateTranslationHTML(
  100. "dialog.reservationErrorMsg", {code: code, msg: msg});
  101. messageHandler.openDialog(
  102. "dialog.reservationError", message, true, {}, () => false);
  103. };
  104. /**
  105. * Notify user that he has been kicked from the server.
  106. */
  107. UI.notifyKicked = function () {
  108. messageHandler.openMessageDialog(
  109. "dialog.sessTerminated",
  110. "dialog.kickMessage");
  111. };
  112. /**
  113. * Notify user that conference was destroyed.
  114. * @param reason {string} the reason text
  115. */
  116. UI.notifyConferenceDestroyed = function (reason) {
  117. //FIXME: use Session Terminated from translation, but
  118. // 'reason' text comes from XMPP packet and is not translated
  119. messageHandler.openDialog(
  120. "dialog.sessTerminated", reason, true, {}, () => false);
  121. };
  122. /**
  123. * Show chat error.
  124. * @param err the Error
  125. * @param msg
  126. */
  127. UI.showChatError = function (err, msg) {
  128. if (interfaceConfig.filmStripOnly) {
  129. return;
  130. }
  131. Chat.chatAddError(err, msg);
  132. };
  133. /**
  134. * Change nickname for the user.
  135. * @param {string} id user id
  136. * @param {string} displayName new nickname
  137. */
  138. UI.changeDisplayName = function (id, displayName) {
  139. if (UI.ContactList)
  140. UI.ContactList.onDisplayNameChange(id, displayName);
  141. VideoLayout.onDisplayNameChanged(id, displayName);
  142. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  143. Profile.changeDisplayName(displayName);
  144. Chat.setChatConversationMode(!!displayName);
  145. }
  146. };
  147. /**
  148. * Shows/hides the indication about local connection being interrupted.
  149. *
  150. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  151. * currently in the interrupted state or <tt>false</tt> if the connection
  152. * is fine.
  153. */
  154. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  155. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  156. };
  157. /**
  158. * Sets the "raised hand" status for a participant.
  159. */
  160. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  161. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  162. if (raisedHandStatus) {
  163. messageHandler.participantNotification(participant.getDisplayName(),
  164. 'notify.somebody', 'connected', 'notify.raisedHand');
  165. }
  166. };
  167. /**
  168. * Sets the local "raised hand" status.
  169. */
  170. UI.setLocalRaisedHandStatus
  171. = raisedHandStatus =>
  172. VideoLayout.setRaisedHandStatus(
  173. APP.conference.getMyUserId(),
  174. raisedHandStatus);
  175. /**
  176. * Initialize conference UI.
  177. */
  178. UI.initConference = function () {
  179. let id = APP.conference.getMyUserId();
  180. // Add myself to the contact list.
  181. if (UI.ContactList)
  182. UI.ContactList.addContact(id, true);
  183. // Update default button states before showing the toolbar
  184. // if local role changes buttons state will be again updated.
  185. UI.updateLocalRole(APP.conference.isModerator);
  186. UI.showToolbar();
  187. let displayName = config.displayJids ? id : Settings.getDisplayName();
  188. if (displayName) {
  189. UI.changeDisplayName('localVideoContainer', displayName);
  190. }
  191. // Make sure we configure our avatar id, before creating avatar for us
  192. let email = Settings.getEmail();
  193. if (email) {
  194. UI.setUserEmail(id, email);
  195. } else {
  196. UI.setUserAvatarID(id, Settings.getAvatarId());
  197. }
  198. APP.store.dispatch(checkAutoEnableDesktopSharing());
  199. if(!interfaceConfig.filmStripOnly) {
  200. Feedback.init(eventEmitter);
  201. }
  202. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  203. // other participants' UI. Consequently, it needs (1) read and write access
  204. // to the UI (depending on the moderator role of the local participant) and
  205. // (2) APP.conference as means of communication between the participants.
  206. followMeHandler = new FollowMe(APP.conference, UI);
  207. UIUtil.activateTooltips();
  208. };
  209. UI.mucJoined = function () {
  210. VideoLayout.mucJoined();
  211. // Update local video now that a conference is joined a user ID should be
  212. // set.
  213. UI.changeDisplayName('localVideoContainer', APP.settings.getDisplayName());
  214. };
  215. /***
  216. * Handler for toggling filmstrip
  217. */
  218. UI.handleToggleFilmstrip = () => UI.toggleFilmstrip();
  219. /**
  220. * Sets tooltip defaults.
  221. *
  222. * @private
  223. */
  224. function _setTooltipDefaults() {
  225. $.fn.tooltip.defaults = {
  226. opacity: 1, //defaults to 1
  227. offset: 1,
  228. delayIn: 0, //defaults to 500
  229. hoverable: true,
  230. hideOnClick: true,
  231. aria: true
  232. };
  233. }
  234. /**
  235. * Returns the shared document manager object.
  236. * @return {EtherpadManager} the shared document manager object
  237. */
  238. UI.getSharedVideoManager = function () {
  239. return sharedVideoManager;
  240. };
  241. /**
  242. * Starts the UI module and initializes all related components.
  243. *
  244. * @returns {boolean} true if the UI is ready and the conference should be
  245. * established, false - otherwise (for example in the case of welcome page)
  246. */
  247. UI.start = function () {
  248. document.title = interfaceConfig.APP_NAME;
  249. // Set the defaults for prompt dialogs.
  250. $.prompt.setDefaults({persistent: false});
  251. // Set the defaults for tooltips.
  252. _setTooltipDefaults();
  253. SideContainerToggler.init(eventEmitter);
  254. Filmstrip.init(eventEmitter);
  255. // By default start with remote videos hidden and rely on other logic to
  256. // make them visible.
  257. UI.setRemoteThumbnailsVisibility(false);
  258. VideoLayout.init(eventEmitter);
  259. if (!interfaceConfig.filmStripOnly) {
  260. VideoLayout.initLargeVideo();
  261. }
  262. VideoLayout.resizeVideoArea(true, true);
  263. sharedVideoManager = new SharedVideoManager(eventEmitter);
  264. if (!interfaceConfig.filmStripOnly) {
  265. let debouncedShowToolbar
  266. = debounce(
  267. () => UI.showToolbar(),
  268. 100,
  269. { leading: true, trailing: false });
  270. $("#videoconference_page").mousemove(debouncedShowToolbar);
  271. // Initialise the recording module.
  272. if (config.enableRecording) {
  273. Recording.init(eventEmitter, config.recordingType);
  274. }
  275. // Initialize side panels
  276. SidePanels.init(eventEmitter);
  277. } else {
  278. $("body").addClass("filmstrip-only");
  279. UI.showToolbar();
  280. Filmstrip.setFilmstripOnly();
  281. APP.store.dispatch(setNotificationsEnabled(false));
  282. JitsiPopover.enabled = false;
  283. }
  284. if (interfaceConfig.VERTICAL_FILMSTRIP) {
  285. $("body").addClass("vertical-filmstrip");
  286. }
  287. document.title = interfaceConfig.APP_NAME;
  288. };
  289. /**
  290. * Invokes cleanup of any deferred execution within relevant UI modules.
  291. *
  292. * @returns {void}
  293. */
  294. UI.stopDaemons = () => {
  295. VideoLayout.resetLargeVideo();
  296. };
  297. /**
  298. * Setup some UI event listeners.
  299. */
  300. UI.registerListeners
  301. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  302. /**
  303. * Unregister some UI event listeners.
  304. */
  305. UI.unregisterListeners
  306. = () => UIListeners.forEach((value, key) => UI.removeListener(key, value));
  307. /**
  308. * Setup some DOM event listeners.
  309. */
  310. UI.bindEvents = () => {
  311. function onResize() {
  312. SideContainerToggler.resize();
  313. VideoLayout.resizeVideoArea();
  314. }
  315. // Resize and reposition videos in full screen mode.
  316. $(document).on(
  317. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  318. () => {
  319. eventEmitter.emit(
  320. UIEvents.FULLSCREEN_TOGGLED,
  321. UIUtil.isFullScreen());
  322. onResize();
  323. });
  324. $(window).resize(onResize);
  325. };
  326. /**
  327. * Unbind some DOM event listeners.
  328. */
  329. UI.unbindEvents = () => {
  330. $(document).off(
  331. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  332. $(window).off('resize');
  333. };
  334. /**
  335. * Show local stream on UI.
  336. * @param {JitsiTrack} track stream to show
  337. */
  338. UI.addLocalStream = track => {
  339. switch (track.getType()) {
  340. case 'audio':
  341. VideoLayout.changeLocalAudio(track);
  342. break;
  343. case 'video':
  344. VideoLayout.changeLocalVideo(track);
  345. break;
  346. default:
  347. logger.error("Unknown stream type: " + track.getType());
  348. break;
  349. }
  350. };
  351. /**
  352. * Show remote stream on UI.
  353. * @param {JitsiTrack} track stream to show
  354. */
  355. UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
  356. /**
  357. * Removed remote stream from UI.
  358. * @param {JitsiTrack} track stream to remove
  359. */
  360. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  361. /**
  362. * Update chat subject.
  363. * @param {string} subject new chat subject
  364. */
  365. UI.setSubject = subject => Chat.setSubject(subject);
  366. /**
  367. * Setup and show Etherpad.
  368. * @param {string} name etherpad id
  369. */
  370. UI.initEtherpad = name => {
  371. if (etherpadManager || !config.etherpad_base || !name) {
  372. return;
  373. }
  374. logger.log('Etherpad is enabled');
  375. etherpadManager
  376. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  377. APP.store.dispatch(showEtherpadButton());
  378. };
  379. /**
  380. * Returns the shared document manager object.
  381. * @return {EtherpadManager} the shared document manager object
  382. */
  383. UI.getSharedDocumentManager = () => etherpadManager;
  384. /**
  385. * Show user on UI.
  386. * @param {JitsiParticipant} user
  387. */
  388. UI.addUser = function (user) {
  389. var id = user.getId();
  390. var displayName = user.getDisplayName();
  391. if (UI.ContactList)
  392. UI.ContactList.addContact(id);
  393. messageHandler.participantNotification(
  394. displayName,'notify.somebody', 'connected', 'notify.connected'
  395. );
  396. if (!config.startAudioMuted ||
  397. config.startAudioMuted > APP.conference.membersCount)
  398. UIUtil.playSoundNotification('userJoined');
  399. // Add Peer's container
  400. VideoLayout.addParticipantContainer(user);
  401. // Configure avatar
  402. UI.setUserEmail(id);
  403. // set initial display name
  404. if(displayName)
  405. UI.changeDisplayName(id, displayName);
  406. };
  407. /**
  408. * Remove user from UI.
  409. * @param {string} id user id
  410. * @param {string} displayName user nickname
  411. */
  412. UI.removeUser = function (id, displayName) {
  413. if (UI.ContactList)
  414. UI.ContactList.removeContact(id);
  415. messageHandler.participantNotification(
  416. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  417. );
  418. if (!config.startAudioMuted
  419. || config.startAudioMuted > APP.conference.membersCount) {
  420. UIUtil.playSoundNotification('userLeft');
  421. }
  422. VideoLayout.removeParticipantContainer(id);
  423. };
  424. /**
  425. * Update videotype for specified user.
  426. * @param {string} id user id
  427. * @param {string} newVideoType new videotype
  428. */
  429. UI.onPeerVideoTypeChanged
  430. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  431. /**
  432. * Update local user role and show notification if user is moderator.
  433. * @param {boolean} isModerator if local user is moderator or not
  434. */
  435. UI.updateLocalRole = isModerator => {
  436. VideoLayout.showModeratorIndicator();
  437. APP.store.dispatch(showDialOutButton(isModerator));
  438. APP.store.dispatch(showSharedVideoButton());
  439. Recording.showRecordingButton(isModerator);
  440. SettingsMenu.showStartMutedOptions(isModerator);
  441. SettingsMenu.showFollowMeOptions(isModerator);
  442. if (isModerator) {
  443. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  444. messageHandler.participantNotification(
  445. null, "notify.me", 'connected', "notify.moderator");
  446. Recording.checkAutoRecord();
  447. }
  448. };
  449. /**
  450. * Check the role for the user and reflect it in the UI, moderator ui indication
  451. * and notifies user who is the moderator
  452. * @param user to check for moderator
  453. */
  454. UI.updateUserRole = user => {
  455. VideoLayout.showModeratorIndicator();
  456. // We don't need to show moderator notifications when the focus (moderator)
  457. // indicator is disabled.
  458. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  459. return;
  460. }
  461. var displayName = user.getDisplayName();
  462. if (displayName) {
  463. messageHandler.participantNotification(
  464. displayName, 'notify.somebody',
  465. 'connected', 'notify.grantedTo', {
  466. to: UIUtil.escapeHtml(displayName)
  467. }
  468. );
  469. } else {
  470. messageHandler.participantNotification(
  471. '', 'notify.somebody',
  472. 'connected', 'notify.grantedToUnknown');
  473. }
  474. };
  475. /**
  476. * Updates the user status.
  477. *
  478. * @param {JitsiParticipant} user - The user which status we need to update.
  479. * @param {string} status - The new status.
  480. */
  481. UI.updateUserStatus = (user, status) => {
  482. let displayName = user.getDisplayName();
  483. messageHandler.participantNotification(
  484. displayName, '', 'connected', "dialOut.statusMessage",
  485. {
  486. status: UIUtil.escapeHtml(status)
  487. });
  488. };
  489. /**
  490. * Toggles smileys in the chat.
  491. */
  492. UI.toggleSmileys = () => Chat.toggleSmileys();
  493. /**
  494. * Toggles filmstrip.
  495. */
  496. UI.toggleFilmstrip = function () {
  497. var self = Filmstrip;
  498. self.toggleFilmstrip.apply(self, arguments);
  499. VideoLayout.resizeVideoArea(true, false);
  500. };
  501. /**
  502. * Indicates if the filmstrip is currently visible or not.
  503. * @returns {true} if the filmstrip is currently visible, otherwise
  504. */
  505. UI.isFilmstripVisible = () => Filmstrip.isFilmstripVisible();
  506. /**
  507. * Toggles chat panel.
  508. */
  509. UI.toggleChat = () => UI.toggleSidePanel("chat_container");
  510. /**
  511. * Toggles contact list panel.
  512. */
  513. UI.toggleContactList = () => UI.toggleSidePanel("contacts_container");
  514. /**
  515. * Toggles the given side panel.
  516. *
  517. * @param {String} sidePanelId the identifier of the side panel to toggle
  518. */
  519. UI.toggleSidePanel = sidePanelId => SideContainerToggler.toggle(sidePanelId);
  520. /**
  521. * Handle new user display name.
  522. */
  523. UI.inputDisplayNameHandler = function (newDisplayName) {
  524. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  525. };
  526. /**
  527. * Show custom popup/tooltip for a specified button.
  528. * @param popupSelectorID the selector id of the popup to show
  529. * @param show true or false/show or hide the popup
  530. * @param timeout the time to show the popup
  531. */
  532. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  533. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  534. popupSelectorID, show, timeout);
  535. };
  536. /**
  537. * Return the type of the remote video.
  538. * @param jid the jid for the remote video
  539. * @returns the video type video or screen.
  540. */
  541. UI.getRemoteVideoType = function (jid) {
  542. return VideoLayout.getRemoteVideoType(jid);
  543. };
  544. // FIXME check if someone user this
  545. UI.showLoginPopup = function(callback) {
  546. logger.log('password is required');
  547. let message = (
  548. `<input name="username" type="text"
  549. placeholder="user@domain.net"
  550. class="input-control" autofocus>
  551. <input name="password" type="password"
  552. data-i18n="[placeholder]dialog.userPassword"
  553. class="input-control"
  554. placeholder="user password">`
  555. );
  556. let submitFunction = (e, v, m, f) => {
  557. if (v) {
  558. if (f.username && f.password) {
  559. callback(f.username, f.password);
  560. }
  561. }
  562. };
  563. messageHandler.openTwoButtonDialog({
  564. titleKey : "dialog.passwordRequired",
  565. msgString: message,
  566. leftButtonKey: 'dialog.Ok',
  567. submitFunction,
  568. focus: ':input:first'
  569. });
  570. };
  571. UI.askForNickname = function () {
  572. return window.prompt('Your nickname (optional)');
  573. };
  574. /**
  575. * Sets muted audio state for participant
  576. */
  577. UI.setAudioMuted = function (id, muted) {
  578. VideoLayout.onAudioMute(id, muted);
  579. if (APP.conference.isLocalId(id)) {
  580. APP.store.dispatch(setAudioMuted(muted));
  581. APP.conference.updateAudioIconEnabled();
  582. }
  583. };
  584. /**
  585. * Sets muted video state for participant
  586. */
  587. UI.setVideoMuted = function (id, muted) {
  588. VideoLayout.onVideoMute(id, muted);
  589. if (APP.conference.isLocalId(id)) {
  590. APP.store.dispatch(setVideoMuted(muted));
  591. APP.conference.updateVideoIconEnabled();
  592. }
  593. };
  594. /**
  595. * Triggers an update of remote video and large video displays so they may pick
  596. * up any state changes that have occurred elsewhere.
  597. *
  598. * @returns {void}
  599. */
  600. UI.updateAllVideos = () => VideoLayout.updateAllVideos();
  601. /**
  602. * Adds a listener that would be notified on the given type of event.
  603. *
  604. * @param type the type of the event we're listening for
  605. * @param listener a function that would be called when notified
  606. */
  607. UI.addListener = function (type, listener) {
  608. eventEmitter.on(type, listener);
  609. };
  610. /**
  611. * Removes the given listener for the given type of event.
  612. *
  613. * @param type the type of the event we're listening for
  614. * @param listener the listener we want to remove
  615. */
  616. UI.removeListener = function (type, listener) {
  617. eventEmitter.removeListener(type, listener);
  618. };
  619. /**
  620. * Emits the event of given type by specifying the parameters in options.
  621. *
  622. * @param type the type of the event we're emitting
  623. * @param options the parameters for the event
  624. */
  625. UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
  626. UI.clickOnVideo = function (videoNumber) {
  627. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  628. let videosLength = videos.length;
  629. if(videosLength <= videoNumber) {
  630. return;
  631. }
  632. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  633. videos[videoIndex].click();
  634. };
  635. // Used by torture.
  636. UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
  637. // Used by torture.
  638. UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
  639. /**
  640. * Updates the avatar for participant.
  641. * @param {string} id user id
  642. * @param {string} avatarUrl the URL for the avatar
  643. */
  644. function changeAvatar(id, avatarUrl) {
  645. VideoLayout.changeUserAvatar(id, avatarUrl);
  646. if (UI.ContactList)
  647. UI.ContactList.changeUserAvatar(id, avatarUrl);
  648. if (APP.conference.isLocalId(id)) {
  649. Profile.changeAvatar(avatarUrl);
  650. }
  651. }
  652. /**
  653. * Update user email.
  654. * @param {string} id user id
  655. * @param {string} email user email
  656. */
  657. UI.setUserEmail = function (id, email) {
  658. // update avatar
  659. Avatar.setUserEmail(id, email);
  660. changeAvatar(id, Avatar.getAvatarUrl(id));
  661. if (APP.conference.isLocalId(id)) {
  662. Profile.changeEmail(email);
  663. }
  664. };
  665. /**
  666. * Update user avtar id.
  667. * @param {string} id user id
  668. * @param {string} avatarId user's avatar id
  669. */
  670. UI.setUserAvatarID = function (id, avatarId) {
  671. // update avatar
  672. Avatar.setUserAvatarID(id, avatarId);
  673. changeAvatar(id, Avatar.getAvatarUrl(id));
  674. };
  675. /**
  676. * Update user avatar URL.
  677. * @param {string} id user id
  678. * @param {string} url user avatar url
  679. */
  680. UI.setUserAvatarUrl = function (id, url) {
  681. // update avatar
  682. Avatar.setUserAvatarUrl(id, url);
  683. changeAvatar(id, Avatar.getAvatarUrl(id));
  684. };
  685. /**
  686. * Notify user that connection failed.
  687. * @param {string} stropheErrorMsg raw Strophe error message
  688. */
  689. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  690. var message;
  691. if (stropheErrorMsg) {
  692. message = APP.translation.generateTranslationHTML(
  693. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  694. } else {
  695. message = APP.translation.generateTranslationHTML(
  696. "dialog.connectError");
  697. }
  698. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  699. };
  700. /**
  701. * Notify user that maximum users limit has been reached.
  702. */
  703. UI.notifyMaxUsersLimitReached = function () {
  704. var message = APP.translation.generateTranslationHTML(
  705. "dialog.maxUsersLimitReached");
  706. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  707. };
  708. /**
  709. * Notify user that he was automatically muted when joned the conference.
  710. */
  711. UI.notifyInitiallyMuted = function () {
  712. messageHandler.participantNotification(
  713. null,
  714. "notify.mutedTitle",
  715. "connected",
  716. "notify.muted",
  717. null,
  718. 120000);
  719. };
  720. /**
  721. * Mark user as dominant speaker.
  722. * @param {string} id user id
  723. */
  724. UI.markDominantSpeaker = function (id) {
  725. VideoLayout.onDominantSpeakerChanged(id);
  726. };
  727. UI.handleLastNEndpoints = function (leavingIds, enteringIds) {
  728. VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
  729. };
  730. /**
  731. * Will handle notification about participant's connectivity status change.
  732. *
  733. * @param {string} id the id of remote participant(MUC jid)
  734. */
  735. UI.participantConnectionStatusChanged = function (id) {
  736. VideoLayout.onParticipantConnectionStatusChanged(id);
  737. };
  738. /**
  739. * Prompt user for nickname.
  740. */
  741. UI.promptDisplayName = () => {
  742. const labelKey = 'dialog.enterDisplayName';
  743. const message = (
  744. `<div class="form-control">
  745. <label data-i18n="${labelKey}" class="form-control__label"></label>
  746. <input name="displayName" type="text"
  747. data-i18n="[placeholder]defaultNickname"
  748. class="input-control" autofocus>
  749. </div>`
  750. );
  751. // Don't use a translation string, because we're too early in the call and
  752. // the translation may not be initialised.
  753. const buttons = { Ok: true };
  754. const dialog = messageHandler.openDialog(
  755. 'dialog.displayNameRequired',
  756. message,
  757. true,
  758. buttons,
  759. (e, v, m, f) => {
  760. e.preventDefault();
  761. if (v) {
  762. const displayName = f.displayName;
  763. if (displayName) {
  764. UI.inputDisplayNameHandler(displayName);
  765. dialog.close();
  766. return;
  767. }
  768. }
  769. },
  770. () => {
  771. const form = $.prompt.getPrompt();
  772. const input = form.find("input[name='displayName']");
  773. const button = form.find("button");
  774. input.focus();
  775. button.attr("disabled", "disabled");
  776. input.keyup(() => {
  777. if (input.val()) {
  778. button.removeAttr("disabled");
  779. } else {
  780. button.attr("disabled", "disabled");
  781. }
  782. });
  783. }
  784. );
  785. };
  786. /**
  787. * Update audio level visualization for specified user.
  788. * @param {string} id user id
  789. * @param {number} lvl audio level
  790. */
  791. UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
  792. /**
  793. * Update state of desktop sharing buttons.
  794. *
  795. * @returns {void}
  796. */
  797. UI.updateDesktopSharingButtons
  798. = () =>
  799. APP.store.dispatch(setToolbarButton('desktop', {
  800. toggled: APP.conference.isSharingScreen
  801. }));
  802. /**
  803. * Hide connection quality statistics from UI.
  804. */
  805. UI.hideStats = function () {
  806. VideoLayout.hideStats();
  807. };
  808. /**
  809. * Mark video as interrupted or not.
  810. * @param {boolean} interrupted if video is interrupted
  811. */
  812. UI.markVideoInterrupted = function (interrupted) {
  813. if (interrupted) {
  814. VideoLayout.onVideoInterrupted();
  815. } else {
  816. VideoLayout.onVideoRestored();
  817. }
  818. };
  819. /**
  820. * Add chat message.
  821. * @param {string} from user id
  822. * @param {string} displayName user nickname
  823. * @param {string} message message text
  824. * @param {number} stamp timestamp when message was created
  825. */
  826. UI.addMessage = function (from, displayName, message, stamp) {
  827. Chat.updateChatConversation(from, displayName, message, stamp);
  828. };
  829. UI.updateDTMFSupport
  830. = isDTMFSupported => APP.store.dispatch(showDialPadButton(isDTMFSupported));
  831. /**
  832. * Show user feedback dialog if its required and enabled after pressing the
  833. * hangup button.
  834. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  835. * resolved with true if the dialog is disabled or the feedback was already
  836. * submitted. Rejected if another dialog is already displayed. This values are
  837. * used to display or not display the thank you dialog from
  838. * conference.maybeRedirectToWelcomePage method.
  839. */
  840. UI.requestFeedbackOnHangup = function () {
  841. if (Feedback.isVisible())
  842. return Promise.reject(FEEDBACK_REQUEST_IN_PROGRESS);
  843. // Feedback has been submitted already.
  844. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  845. return Promise.resolve({
  846. thankYouDialogVisible : true,
  847. feedbackSubmitted: true
  848. });
  849. }
  850. else
  851. return new Promise(function (resolve) {
  852. if (Feedback.isEnabled()) {
  853. Feedback.openFeedbackWindow(
  854. (options) => {
  855. options.thankYouDialogVisible = false;
  856. resolve(options);
  857. });
  858. } else {
  859. // If the feedback functionality isn't enabled we show a thank
  860. // you dialog. Signaling it (true), so the caller
  861. // of requestFeedback can act on it
  862. resolve(
  863. {thankYouDialogVisible : true, feedbackSubmitted: false});
  864. }
  865. });
  866. };
  867. UI.updateRecordingState = function (state) {
  868. Recording.updateRecordingState(state);
  869. };
  870. UI.notifyTokenAuthFailed = function () {
  871. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  872. "dialog.tokenAuthFailed");
  873. };
  874. UI.notifyInternalError = function () {
  875. messageHandler.showError( "dialog.internalErrorTitle",
  876. "dialog.internalError");
  877. };
  878. UI.notifyFocusDisconnected = function (focus, retrySec) {
  879. messageHandler.participantNotification(
  880. null, "notify.focus",
  881. 'disconnected', "notify.focusFail",
  882. {component: focus, ms: retrySec}
  883. );
  884. };
  885. /**
  886. * Updates auth info on the UI.
  887. * @param {boolean} isAuthEnabled if authentication is enabled
  888. * @param {string} [login] current login
  889. */
  890. UI.updateAuthInfo = function (isAuthEnabled, login) {
  891. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  892. let loggedIn = !!login;
  893. Profile.showAuthenticationButtons(showAuth);
  894. if (showAuth) {
  895. Profile.setAuthenticatedIdentity(login);
  896. Profile.showLoginButton(!loggedIn);
  897. Profile.showLogoutButton(loggedIn);
  898. }
  899. };
  900. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  901. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  902. };
  903. /**
  904. * Notifies interested listeners that the raise hand property has changed.
  905. *
  906. * @param {boolean} isRaisedHand indicates the current state of the
  907. * "raised hand"
  908. */
  909. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  910. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  911. };
  912. /**
  913. * Update list of available physical devices.
  914. * @param {object[]} devices new list of available devices
  915. */
  916. UI.onAvailableDevicesChanged = function (devices) {
  917. APP.store.dispatch(updateDeviceList(devices));
  918. APP.conference.updateAudioIconEnabled();
  919. APP.conference.updateVideoIconEnabled();
  920. };
  921. /**
  922. * Returns the id of the current video shown on large.
  923. * Currently used by tests (torture).
  924. */
  925. UI.getLargeVideoID = function () {
  926. return VideoLayout.getLargeVideoID();
  927. };
  928. /**
  929. * Returns the current video shown on large.
  930. * Currently used by tests (torture).
  931. */
  932. UI.getLargeVideo = function () {
  933. return VideoLayout.getLargeVideo();
  934. };
  935. /**
  936. * Returns whether or not the passed in user id is currently pinned to the large
  937. * video.
  938. *
  939. * @param {string} userId - The id of the user to check is pinned or not.
  940. * @returns {boolean} True if the user is currently pinned to the large video.
  941. */
  942. UI.isPinned = userId => VideoLayout.getPinnedId() === userId;
  943. /**
  944. * Shows dialog with a link to FF extension.
  945. */
  946. UI.showExtensionRequiredDialog = function (url) {
  947. messageHandler.openMessageDialog(
  948. "dialog.extensionRequired",
  949. "[html]dialog.firefoxExtensionPrompt",
  950. {url: url});
  951. };
  952. /**
  953. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  954. * 2 button dialog with buttons - cancel and go to web store.
  955. * @param url {string} the url of the extension.
  956. */
  957. UI.showExtensionExternalInstallationDialog = function (url) {
  958. let openedWindow = null;
  959. let submitFunction = function(e,v){
  960. if (v) {
  961. e.preventDefault();
  962. if (openedWindow === null || openedWindow.closed) {
  963. openedWindow
  964. = window.open(
  965. url,
  966. "extension_store_window",
  967. "resizable,scrollbars=yes,status=1");
  968. } else {
  969. openedWindow.focus();
  970. }
  971. }
  972. };
  973. let closeFunction = function (e, v) {
  974. if (openedWindow) {
  975. // Ideally we would close the popup, but this does not seem to work
  976. // on Chrome. Leaving it uncommented in case it could work
  977. // in some version.
  978. openedWindow.close();
  979. openedWindow = null;
  980. }
  981. if (!v) {
  982. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  983. }
  984. };
  985. messageHandler.openTwoButtonDialog({
  986. titleKey: 'dialog.externalInstallationTitle',
  987. msgKey: 'dialog.externalInstallationMsg',
  988. leftButtonKey: 'dialog.goToStore',
  989. submitFunction,
  990. loadedFunction: $.noop,
  991. closeFunction
  992. });
  993. };
  994. /**
  995. * Shows a dialog which asks user to install the extension. This one is
  996. * displayed after installation is triggered from the script, but fails because
  997. * it must be initiated by user gesture.
  998. * @param callback {function} function to be executed after user clicks
  999. * the install button - it should make another attempt to install the extension.
  1000. */
  1001. UI.showExtensionInlineInstallationDialog = function (callback) {
  1002. let submitFunction = function(e,v){
  1003. if (v) {
  1004. callback();
  1005. }
  1006. };
  1007. let closeFunction = function (e, v) {
  1008. if (!v) {
  1009. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1010. }
  1011. };
  1012. messageHandler.openTwoButtonDialog({
  1013. titleKey: 'dialog.externalInstallationTitle',
  1014. msgKey: 'dialog.inlineInstallationMsg',
  1015. leftButtonKey: 'dialog.inlineInstallExtension',
  1016. submitFunction,
  1017. loadedFunction: $.noop,
  1018. closeFunction
  1019. });
  1020. };
  1021. /**
  1022. * Shows a notifications about the passed in microphone error.
  1023. *
  1024. * @param {JitsiTrackError} micError - An error object related to using or
  1025. * acquiring an audio stream.
  1026. * @returns {void}
  1027. */
  1028. UI.showMicErrorNotification = function (micError) {
  1029. if (!micError) {
  1030. return;
  1031. }
  1032. const { message, name } = micError;
  1033. const persistenceKey = `doNotShowErrorAgain-mic-${name}`;
  1034. const micJitsiTrackErrorMsg
  1035. = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[name];
  1036. const micErrorMsg = micJitsiTrackErrorMsg
  1037. || JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL];
  1038. const additionalMicErrorMsg = micJitsiTrackErrorMsg ? null : message;
  1039. APP.store.dispatch(maybeShowNotificationWithDoNotDisplay(
  1040. persistenceKey,
  1041. {
  1042. additionalMessage: additionalMicErrorMsg,
  1043. messageKey: micErrorMsg,
  1044. showToggle: Boolean(micJitsiTrackErrorMsg),
  1045. subtitleKey: 'dialog.micErrorPresent',
  1046. titleKey: name === TrackErrors.PERMISSION_DENIED
  1047. ? 'deviceError.microphonePermission' : 'dialog.error',
  1048. toggleLabelKey: 'dialog.doNotShowWarningAgain'
  1049. }));
  1050. };
  1051. /**
  1052. * Shows a notifications about the passed in camera error.
  1053. *
  1054. * @param {JitsiTrackError} cameraError - An error object related to using or
  1055. * acquiring a video stream.
  1056. * @returns {void}
  1057. */
  1058. UI.showCameraErrorNotification = function (cameraError) {
  1059. if (!cameraError) {
  1060. return;
  1061. }
  1062. const { message, name } = cameraError;
  1063. const persistenceKey = `doNotShowErrorAgain-camera-${name}`;
  1064. const cameraJitsiTrackErrorMsg =
  1065. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[name];
  1066. const cameraErrorMsg = cameraJitsiTrackErrorMsg
  1067. || JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL];
  1068. const additionalCameraErrorMsg = cameraJitsiTrackErrorMsg ? null : message;
  1069. APP.store.dispatch(maybeShowNotificationWithDoNotDisplay(
  1070. persistenceKey,
  1071. {
  1072. additionalMessage: additionalCameraErrorMsg,
  1073. messageKey: cameraErrorMsg,
  1074. showToggle: Boolean(cameraJitsiTrackErrorMsg),
  1075. subtitleKey: 'dialog.cameraErrorPresent',
  1076. titleKey: name === TrackErrors.PERMISSION_DENIED
  1077. ? 'deviceError.cameraPermission' : 'dialog.error',
  1078. toggleLabelKey: 'dialog.doNotShowWarningAgain'
  1079. }));
  1080. };
  1081. /**
  1082. * Shows error dialog that informs the user that no data is received from the
  1083. * device.
  1084. */
  1085. UI.showTrackNotWorkingDialog = function (stream) {
  1086. messageHandler.openMessageDialog(
  1087. "dialog.error",
  1088. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1089. "dialog.cameraNotSendingData");
  1090. };
  1091. UI.updateDevicesAvailability = function (id, devices) {
  1092. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1093. };
  1094. /**
  1095. * Show shared video.
  1096. * @param {string} id the id of the sender of the command
  1097. * @param {string} url video url
  1098. * @param {string} attributes
  1099. */
  1100. UI.onSharedVideoStart = function (id, url, attributes) {
  1101. if (sharedVideoManager)
  1102. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1103. };
  1104. /**
  1105. * Update shared video.
  1106. * @param {string} id the id of the sender of the command
  1107. * @param {string} url video url
  1108. * @param {string} attributes
  1109. */
  1110. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1111. if (sharedVideoManager)
  1112. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1113. };
  1114. /**
  1115. * Stop showing shared video.
  1116. * @param {string} id the id of the sender of the command
  1117. * @param {string} attributes
  1118. */
  1119. UI.onSharedVideoStop = function (id, attributes) {
  1120. if (sharedVideoManager)
  1121. sharedVideoManager.onSharedVideoStop(id, attributes);
  1122. };
  1123. /**
  1124. * Handles user's features changes.
  1125. */
  1126. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  1127. /**
  1128. * Returns the number of known remote videos.
  1129. *
  1130. * @returns {number} The number of remote videos.
  1131. */
  1132. UI.getRemoteVideosCount = () => VideoLayout.getRemoteVideosCount();
  1133. /**
  1134. * Makes remote thumbnail videos visible or not visible.
  1135. *
  1136. * @param {boolean} shouldHide - True if remote thumbnails should be hidden,
  1137. * false f they should be visible.
  1138. * @returns {void}
  1139. */
  1140. UI.setRemoteThumbnailsVisibility
  1141. = shouldHide => Filmstrip.setRemoteVideoVisibility(shouldHide);
  1142. const UIListeners = new Map([
  1143. [
  1144. UIEvents.ETHERPAD_CLICKED,
  1145. () => etherpadManager && etherpadManager.toggleEtherpad()
  1146. ], [
  1147. UIEvents.SHARED_VIDEO_CLICKED,
  1148. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  1149. ], [
  1150. UIEvents.TOGGLE_FULLSCREEN,
  1151. UI.toggleFullScreen
  1152. ], [
  1153. UIEvents.TOGGLE_CHAT,
  1154. UI.toggleChat
  1155. ], [
  1156. UIEvents.TOGGLE_SETTINGS,
  1157. () => {
  1158. // Opening of device selection is special-cased as it is a dialog
  1159. // opened through a button in settings and not directly displayed in
  1160. // settings itself. As it is not useful to only have a settings menu
  1161. // with a button to open a dialog, open the dialog directly instead.
  1162. if (interfaceConfig.SETTINGS_SECTIONS.length === 1
  1163. && UIUtil.isSettingEnabled('devices')) {
  1164. APP.store.dispatch(openDeviceSelectionDialog());
  1165. } else {
  1166. UI.toggleSidePanel("settings_container");
  1167. }
  1168. }
  1169. ], [
  1170. UIEvents.TOGGLE_CONTACT_LIST,
  1171. UI.toggleContactList
  1172. ], [
  1173. UIEvents.TOGGLE_PROFILE,
  1174. () => {
  1175. const {
  1176. isGuest
  1177. } = APP.store.getState()['features/jwt'];
  1178. isGuest && UI.toggleSidePanel('profile_container');
  1179. }
  1180. ], [
  1181. UIEvents.TOGGLE_FILMSTRIP,
  1182. UI.handleToggleFilmstrip
  1183. ], [
  1184. UIEvents.FOLLOW_ME_ENABLED,
  1185. enabled => (followMeHandler && followMeHandler.enableFollowMe(enabled))
  1186. ]
  1187. ]);
  1188. // TODO: Export every function separately. For now there is no point of doing
  1189. // this because we are importing everything.
  1190. export default UI;