diff --git a/app.js b/app.js index c4d01623a..3b508af75 100644 --- a/app.js +++ b/app.js @@ -17,6 +17,7 @@ import URLProcessor from "./modules/config/URLProcessor"; import RoomnameGenerator from './modules/util/RoomnameGenerator'; import CQEvents from './service/connectionquality/CQEvents'; import UIEvents from './service/UI/UIEvents'; +import DSEvents from './service/desktopsharing/DesktopSharingEventTypes'; import UI from "./modules/UI/UI"; import statistics from "./modules/statistics/statistics"; @@ -27,9 +28,6 @@ import AuthHandler from './modules/AuthHandler'; import createRoomLocker from './modules/RoomLocker'; -const DesktopSharingEventTypes = - require("./service/desktopsharing/DesktopSharingEventTypes"); - const ConnectionEvents = JitsiMeetJS.events.connection; const ConnectionErrors = JitsiMeetJS.errors.connection; @@ -511,8 +509,14 @@ function initConference(localTracks, connection) { APP.UI.updateDTMFSupport(isDTMFSupported); }); + APP.UI.addListener(UIEvents.TOGGLE_SCREENSHARING, function () { + APP.desktopsharing.toggleScreenSharing(); + }); + APP.UI.addListener(DSEvents.SWITCHING_DONE, function (isSharingScreen) { + APP.UI.updateDesktopSharingButtons(isSharingScreen); + }); APP.desktopsharing.addListener( - DesktopSharingEventTypes.NEW_STREAM_CREATED, + DSEvents.NEW_STREAM_CREATED, (track, callback) => { const localCallback = (newTrack) => { if (newTrack.isLocal() && newTrack === localVideo) { diff --git a/modules/UI/UI.js b/modules/UI/UI.js index bf110e072..2a04b4e66 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -11,6 +11,7 @@ import Avatar from "./avatar/Avatar"; import PanelToggler from "./side_pannels/SidePanelToggler"; import UIUtil from "./util/UIUtil"; import UIEvents from "../../service/UI/UIEvents"; +import CQEvents from '../../service/connectionquality/CQEvents'; import PreziManager from './prezi/Prezi'; import EtherpadManager from './etherpad/Etherpad'; @@ -22,9 +23,6 @@ var EventEmitter = require("events"); UI.messageHandler = require("./util/MessageHandler"); var messageHandler = UI.messageHandler; var JitsiPopover = require("./util/JitsiPopover"); -var CQEvents = require("../../service/connectionquality/CQEvents"); -var DesktopSharingEventTypes - = require("../../service/desktopsharing/DesktopSharingEventTypes"); var Feedback = require("./Feedback"); var eventEmitter = new EventEmitter(); @@ -599,8 +597,8 @@ UI.setAudioLevel = function (id, lvl) { VideoLayout.setAudioLevel(id, lvl); }; -UI.updateDesktopSharingButtons = function () { - Toolbar.changeDesktopSharingButtonState(); +UI.updateDesktopSharingButtons = function (isSharingScreen) { + Toolbar.changeDesktopSharingButtonState(isSharingScreen); }; UI.hideStats = function () { diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js index 730195ce1..9993d7c03 100644 --- a/modules/UI/toolbars/Toolbar.js +++ b/modules/UI/toolbars/Toolbar.js @@ -136,7 +136,7 @@ const buttonHandlers = { } else { AnalyticsAdapter.sendEvent('toolbar.screen.enabled'); } - APP.desktopsharing.toggleScreenSharing(); + emitter.emit(UIEvents.TOGGLE_SCREENSHARING); }, "toolbar_button_fullScreen": function() { AnalyticsAdapter.sendEvent('toolbar.fullscreen.enabled'); @@ -309,9 +309,8 @@ const Toolbar = { // checks whether desktop sharing is enabled and whether // we have params to start automatically sharing checkAutoEnableDesktopSharing () { - if (UIUtil.isButtonEnabled('desktop') - && config.autoEnableDesktopSharing) { - APP.desktopsharing.toggleScreenSharing(); + if (UIUtil.isButtonEnabled('desktop') && config.autoEnableDesktopSharing) { + emitter.emit(UIEvents.TOGGLE_SCREENSHARING); } }, diff --git a/modules/desktopsharing/desktopsharing.js b/modules/desktopsharing/desktopsharing.js index 91a616e2d..a4f646d8f 100644 --- a/modules/desktopsharing/desktopsharing.js +++ b/modules/desktopsharing/desktopsharing.js @@ -1,7 +1,6 @@ /* global APP, JitsiMeetJS, config */ var EventEmitter = require("events"); -var DesktopSharingEventTypes - = require("../../service/desktopsharing/DesktopSharingEventTypes"); +import DSEvents from '../../service/desktopsharing/DesktopSharingEventTypes'; const TrackEvents = JitsiMeetJS.events.track; @@ -27,14 +26,11 @@ var eventEmitter = new EventEmitter(); function streamSwitchDone() { switchInProgress = false; - eventEmitter.emit( - DesktopSharingEventTypes.SWITCHING_DONE, - isUsingScreenStream); + eventEmitter.emit(DSEvents.SWITCHING_DONE, isUsingScreenStream); } function newStreamCreated(track) { - eventEmitter.emit(DesktopSharingEventTypes.NEW_STREAM_CREATED, - track, streamSwitchDone); + eventEmitter.emit(DSEvents.NEW_STREAM_CREATED, track, streamSwitchDone); } function getVideoStreamFailed() { diff --git a/service/UI/UIEvents.js b/service/UI/UIEvents.js index 12ffe4be2..cc4263e92 100644 --- a/service/UI/UIEvents.js +++ b/service/UI/UIEvents.js @@ -34,6 +34,7 @@ export default { TOGGLE_SETTINGS: "UI.toggle_settings", TOGGLE_CONTACT_LIST: "UI.toggle_contact_list", TOGGLE_FILM_STRIP: "UI.toggle_film_strip", + TOGGLE_SCREENSHARING: "UI.toggle_screensharing", CONTACT_CLICKED: "UI.contact_clicked", HANGUP: "UI.hangup", LOGOUT: "UI.logout", diff --git a/service/desktopsharing/DesktopSharingEventTypes.js b/service/desktopsharing/DesktopSharingEventTypes.js index 5bf78b748..d41aba69f 100644 --- a/service/desktopsharing/DesktopSharingEventTypes.js +++ b/service/desktopsharing/DesktopSharingEventTypes.js @@ -1,6 +1,4 @@ -var DesktopSharingEventTypes = { - INIT: "ds.init", - +export default { SWITCHING_DONE: "ds.switching_done", NEW_STREAM_CREATED: "ds.new_stream_created", @@ -11,5 +9,3 @@ var DesktopSharingEventTypes = { */ FIREFOX_EXTENSION_NEEDED: "ds.firefox_extension_needed" }; - -module.exports = DesktopSharingEventTypes; \ No newline at end of file