diff --git a/ConferenceEvents.js b/ConferenceEvents.js index 20deec08d3..8fb7a6b663 100644 --- a/ConferenceEvents.js +++ b/ConferenceEvents.js @@ -2,10 +2,3 @@ * Notifies interested parties that hangup procedure will start. */ export const BEFORE_HANGUP = 'conference.before_hangup'; - -/** - * Notifies interested parties that desktop sharing enable/disable state is - * changed. - */ -export const DESKTOP_SHARING_ENABLED_CHANGED - = 'conference.desktop_sharing_enabled_changed'; diff --git a/conference.js b/conference.js index 0726c32c34..3789ea13e9 100644 --- a/conference.js +++ b/conference.js @@ -41,8 +41,7 @@ import { lockStateChanged, onStartMutedPolicyChanged, p2pStatusChanged, - sendLocalParticipant, - setDesktopSharingEnabled + sendLocalParticipant } from './react/features/base/conference'; import { checkAndNotifyForNewDevice, @@ -441,17 +440,8 @@ export default { * the tracks won't exist). */ _localTracksInitialized: false, - isSharingScreen: false, - /** - * Indicates if the desktop sharing functionality has been enabled. - * It takes into consideration the status returned by - * {@link JitsiMeetJS.isDesktopSharingEnabled()}. The latter can be false - * either if the desktop sharing is not supported by the current browser - * or if it was disabled through lib-jitsi-meet specific options (check - * config.js for listed options). - */ - isDesktopSharingEnabled: false, + isSharingScreen: false, /** * The local audio track (if any). @@ -679,14 +669,6 @@ export default { con.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _connectionFailedHandler); APP.connection = connection = con; - // Desktop sharing related stuff: - this.isDesktopSharingEnabled - = JitsiMeetJS.isDesktopSharingEnabled(); - eventEmitter.emit(JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED, this.isDesktopSharingEnabled); - - APP.store.dispatch( - setDesktopSharingEnabled(this.isDesktopSharingEnabled)); - this._createRoom(tracks); APP.remoteControl.init(); @@ -1532,9 +1514,8 @@ export default { if (this.videoSwitchInProgress) { return Promise.reject('Switch in progress.'); } - if (!this.isDesktopSharingEnabled) { - return Promise.reject( - 'Cannot toggle screen sharing: not supported.'); + if (!JitsiMeetJS.isDesktopSharingEnabled()) { + return Promise.reject('Cannot toggle screen sharing: not supported.'); } if (this.isAudioOnly()) { diff --git a/modules/API/API.js b/modules/API/API.js index 397d2a6927..87c7f6f950 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -2,7 +2,6 @@ import Logger from 'jitsi-meet-logger'; -import * as JitsiMeetConferenceEvents from '../../ConferenceEvents'; import { createApiEvent, sendAnalytics @@ -14,7 +13,7 @@ import { setSubject } from '../../react/features/base/conference'; import { parseJWTFromURLParams } from '../../react/features/base/jwt'; -import { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet'; +import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet'; import { pinParticipant } from '../../react/features/base/participants'; import { processExternalDeviceRequest @@ -46,14 +45,6 @@ declare var APP: Object; */ let commands = {}; -/** - * The state of screen sharing(started/stopped) before the screen sharing is - * enabled and initialized. - * NOTE: This flag help us to cache the state and use it if toggle-share-screen - * was received before the initialization. - */ -let initialScreenSharingState = false; - /** * The transport instance used for communication with external apps. * @@ -430,19 +421,6 @@ function initCommands() { }); } -/** - * Listens for desktop/screen sharing enabled events and toggles the screen - * sharing if needed. - * - * @param {boolean} enabled - Current screen sharing enabled status. - * @returns {void} - */ -function onDesktopSharingEnabledChanged(enabled = false) { - if (enabled && initialScreenSharingState) { - toggleScreenSharing(); - } -} - /** * Check whether the API should be enabled or not. * @@ -470,12 +448,10 @@ function shouldBeEnabled() { * @returns {void} */ function toggleScreenSharing(enable) { - if (APP.conference.isDesktopSharingEnabled) { - - // eslint-disable-next-line no-empty-function - APP.conference.toggleScreenSharing(enable).catch(() => {}); - } else { - initialScreenSharingState = !initialScreenSharingState; + if (JitsiMeetJS.isDesktopSharingEnabled()) { + APP.conference.toggleScreenSharing(enable).catch(() => { + logger.warn('Failed to toggle screen-sharing'); + }); } } @@ -508,10 +484,6 @@ class API { */ this._enabled = true; - APP.conference.addListener( - JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED, - onDesktopSharingEnabledChanged); - initCommands(); } @@ -1058,9 +1030,6 @@ class API { dispose() { if (this._enabled) { this._enabled = false; - APP.conference.removeListener( - JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED, - onDesktopSharingEnabledChanged); } } } diff --git a/modules/remotecontrol/RemoteControl.js b/modules/remotecontrol/RemoteControl.js index b139f26e09..d29c48aa49 100644 --- a/modules/remotecontrol/RemoteControl.js +++ b/modules/remotecontrol/RemoteControl.js @@ -3,6 +3,7 @@ import EventEmitter from 'events'; import { getLogger } from 'jitsi-meet-logger'; +import JitsiMeetJS from '../../react/features/base/lib-jitsi-meet'; import { DISCO_REMOTE_CONTROL_FEATURE } from '../../service/remotecontrol/Constants'; import * as RemoteControlEvents @@ -68,9 +69,7 @@ class RemoteControl extends EventEmitter { * @returns {void} */ init() { - if (config.disableRemoteControl - || this._initialized - || !APP.conference.isDesktopSharingEnabled) { + if (config.disableRemoteControl || this._initialized || !JitsiMeetJS.isDesktopSharingEnabled()) { return; } logger.log('Initializing remote control.'); diff --git a/react/features/base/conference/actionTypes.js b/react/features/base/conference/actionTypes.js index eab7340152..21145b0e56 100644 --- a/react/features/base/conference/actionTypes.js +++ b/react/features/base/conference/actionTypes.js @@ -140,18 +140,6 @@ export const P2P_STATUS_CHANGED = 'P2P_STATUS_CHANGED'; */ export const SEND_TONES = 'SEND_TONES'; -/** - * The type of (redux) action which sets the desktop sharing enabled flag for - * the current conference. - * - * { - * type: SET_DESKTOP_SHARING_ENABLED, - * desktopSharingEnabled: boolean - * } - */ -export const SET_DESKTOP_SHARING_ENABLED - = 'SET_DESKTOP_SHARING_ENABLED'; - /** * The type of (redux) action which updates the current known status of the * Follow Me feature. diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 5285b6b0bb..4739bc61e6 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -43,7 +43,6 @@ import { LOCK_STATE_CHANGED, P2P_STATUS_CHANGED, SEND_TONES, - SET_DESKTOP_SHARING_ENABLED, SET_FOLLOW_ME, SET_PASSWORD, SET_PASSWORD_FAILED, @@ -573,22 +572,6 @@ export function sendTones(tones: string, duration: number, pause: number) { }; } -/** - * Sets the flag for indicating if desktop sharing is enabled. - * - * @param {boolean} desktopSharingEnabled - True if desktop sharing is enabled. - * @returns {{ - * type: SET_DESKTOP_SHARING_ENABLED, - * desktopSharingEnabled: boolean - * }} - */ -export function setDesktopSharingEnabled(desktopSharingEnabled: boolean) { - return { - type: SET_DESKTOP_SHARING_ENABLED, - desktopSharingEnabled - }; -} - /** * Enables or disables the Follow Me feature. * diff --git a/react/features/base/conference/reducer.js b/react/features/base/conference/reducer.js index d303d0c309..91606c4c2b 100644 --- a/react/features/base/conference/reducer.js +++ b/react/features/base/conference/reducer.js @@ -16,7 +16,6 @@ import { CONFERENCE_WILL_LEAVE, LOCK_STATE_CHANGED, P2P_STATUS_CHANGED, - SET_DESKTOP_SHARING_ENABLED, SET_FOLLOW_ME, SET_PASSWORD, SET_PENDING_SUBJECT_CHANGE, @@ -76,9 +75,6 @@ ReducerRegistry.register( case P2P_STATUS_CHANGED: return _p2pStatusChanged(state, action); - case SET_DESKTOP_SHARING_ENABLED: - return _setDesktopSharingEnabled(state, action); - case SET_FOLLOW_ME: return set(state, 'followMeEnabled', action.enabled); @@ -343,21 +339,6 @@ function _p2pStatusChanged(state, action) { return set(state, 'p2p', action.p2p); } -/** - * Reduces a specific Redux action SET_DESKTOP_SHARING_ENABLED of the feature - * base/conference. - * - * @param {Object} state - The Redux state of the feature base/conference. - * @param {Action} action - The Redux action SET_DESKTOP_SHARING_ENABLED to - * reduce. - * @private - * @returns {Object} The new state of the feature base/conference after the - * reduction of the specified action. - */ -function _setDesktopSharingEnabled(state, action) { - return set(state, 'desktopSharingEnabled', action.desktopSharingEnabled); -} - /** * Reduces a specific Redux action SET_PASSWORD of the feature base/conference. * diff --git a/react/features/toolbox/components/web/Toolbox.js b/react/features/toolbox/components/web/Toolbox.js index fbf6cc8e6c..19dd895bb2 100644 --- a/react/features/toolbox/components/web/Toolbox.js +++ b/react/features/toolbox/components/web/Toolbox.js @@ -25,6 +25,7 @@ import { IconShareDesktop, IconShareVideo } from '../../../base/icons'; +import JitsiMeetJS from '../../../base/lib-jitsi-meet'; import { getLocalParticipant, getParticipants, @@ -1403,7 +1404,7 @@ class Toolbox extends Component { */ function _mapStateToProps(state) { const { conference, locked } = state['features/base/conference']; - let { desktopSharingEnabled } = state['features/base/conference']; + let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled(); const { callStatsID, enableFeaturesBasedOnToken