fix(conference) remove no longer needed code

There is no need for setting the availability of desktop sharing anymore. It can
now be detected on the spot.

The reson for the previous code was that way back when browser extensions were
needed, it was possible to start a conference without desktopo sharing support
and get it afterwards. This is no longer the case.
This commit is contained in:
Saúl Ibarra Corretgé 2020-11-03 10:44:41 +01:00 committed by Saúl Ibarra Corretgé
parent efce5a831b
commit 2a01d3550c
8 changed files with 13 additions and 118 deletions

View File

@ -2,10 +2,3 @@
* Notifies interested parties that hangup procedure will start. * Notifies interested parties that hangup procedure will start.
*/ */
export const BEFORE_HANGUP = 'conference.before_hangup'; 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';

View File

@ -41,8 +41,7 @@ import {
lockStateChanged, lockStateChanged,
onStartMutedPolicyChanged, onStartMutedPolicyChanged,
p2pStatusChanged, p2pStatusChanged,
sendLocalParticipant, sendLocalParticipant
setDesktopSharingEnabled
} from './react/features/base/conference'; } from './react/features/base/conference';
import { import {
checkAndNotifyForNewDevice, checkAndNotifyForNewDevice,
@ -441,17 +440,8 @@ export default {
* the tracks won't exist). * the tracks won't exist).
*/ */
_localTracksInitialized: false, _localTracksInitialized: false,
isSharingScreen: 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,
/** /**
* The local audio track (if any). * The local audio track (if any).
@ -679,14 +669,6 @@ export default {
con.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _connectionFailedHandler); con.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _connectionFailedHandler);
APP.connection = connection = con; 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); this._createRoom(tracks);
APP.remoteControl.init(); APP.remoteControl.init();
@ -1532,9 +1514,8 @@ export default {
if (this.videoSwitchInProgress) { if (this.videoSwitchInProgress) {
return Promise.reject('Switch in progress.'); return Promise.reject('Switch in progress.');
} }
if (!this.isDesktopSharingEnabled) { if (!JitsiMeetJS.isDesktopSharingEnabled()) {
return Promise.reject( return Promise.reject('Cannot toggle screen sharing: not supported.');
'Cannot toggle screen sharing: not supported.');
} }
if (this.isAudioOnly()) { if (this.isAudioOnly()) {

View File

@ -2,7 +2,6 @@
import Logger from 'jitsi-meet-logger'; import Logger from 'jitsi-meet-logger';
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
import { import {
createApiEvent, createApiEvent,
sendAnalytics sendAnalytics
@ -14,7 +13,7 @@ import {
setSubject setSubject
} from '../../react/features/base/conference'; } from '../../react/features/base/conference';
import { parseJWTFromURLParams } from '../../react/features/base/jwt'; 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 { pinParticipant } from '../../react/features/base/participants';
import { import {
processExternalDeviceRequest processExternalDeviceRequest
@ -46,14 +45,6 @@ declare var APP: Object;
*/ */
let commands = {}; 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. * 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. * Check whether the API should be enabled or not.
* *
@ -470,12 +448,10 @@ function shouldBeEnabled() {
* @returns {void} * @returns {void}
*/ */
function toggleScreenSharing(enable) { function toggleScreenSharing(enable) {
if (APP.conference.isDesktopSharingEnabled) { if (JitsiMeetJS.isDesktopSharingEnabled()) {
APP.conference.toggleScreenSharing(enable).catch(() => {
// eslint-disable-next-line no-empty-function logger.warn('Failed to toggle screen-sharing');
APP.conference.toggleScreenSharing(enable).catch(() => {}); });
} else {
initialScreenSharingState = !initialScreenSharingState;
} }
} }
@ -508,10 +484,6 @@ class API {
*/ */
this._enabled = true; this._enabled = true;
APP.conference.addListener(
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
onDesktopSharingEnabledChanged);
initCommands(); initCommands();
} }
@ -1058,9 +1030,6 @@ class API {
dispose() { dispose() {
if (this._enabled) { if (this._enabled) {
this._enabled = false; this._enabled = false;
APP.conference.removeListener(
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
onDesktopSharingEnabledChanged);
} }
} }
} }

View File

@ -3,6 +3,7 @@
import EventEmitter from 'events'; import EventEmitter from 'events';
import { getLogger } from 'jitsi-meet-logger'; import { getLogger } from 'jitsi-meet-logger';
import JitsiMeetJS from '../../react/features/base/lib-jitsi-meet';
import { DISCO_REMOTE_CONTROL_FEATURE } import { DISCO_REMOTE_CONTROL_FEATURE }
from '../../service/remotecontrol/Constants'; from '../../service/remotecontrol/Constants';
import * as RemoteControlEvents import * as RemoteControlEvents
@ -68,9 +69,7 @@ class RemoteControl extends EventEmitter {
* @returns {void} * @returns {void}
*/ */
init() { init() {
if (config.disableRemoteControl if (config.disableRemoteControl || this._initialized || !JitsiMeetJS.isDesktopSharingEnabled()) {
|| this._initialized
|| !APP.conference.isDesktopSharingEnabled) {
return; return;
} }
logger.log('Initializing remote control.'); logger.log('Initializing remote control.');

View File

@ -140,18 +140,6 @@ export const P2P_STATUS_CHANGED = 'P2P_STATUS_CHANGED';
*/ */
export const SEND_TONES = 'SEND_TONES'; 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 * The type of (redux) action which updates the current known status of the
* Follow Me feature. * Follow Me feature.

View File

@ -43,7 +43,6 @@ import {
LOCK_STATE_CHANGED, LOCK_STATE_CHANGED,
P2P_STATUS_CHANGED, P2P_STATUS_CHANGED,
SEND_TONES, SEND_TONES,
SET_DESKTOP_SHARING_ENABLED,
SET_FOLLOW_ME, SET_FOLLOW_ME,
SET_PASSWORD, SET_PASSWORD,
SET_PASSWORD_FAILED, 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. * Enables or disables the Follow Me feature.
* *

View File

@ -16,7 +16,6 @@ import {
CONFERENCE_WILL_LEAVE, CONFERENCE_WILL_LEAVE,
LOCK_STATE_CHANGED, LOCK_STATE_CHANGED,
P2P_STATUS_CHANGED, P2P_STATUS_CHANGED,
SET_DESKTOP_SHARING_ENABLED,
SET_FOLLOW_ME, SET_FOLLOW_ME,
SET_PASSWORD, SET_PASSWORD,
SET_PENDING_SUBJECT_CHANGE, SET_PENDING_SUBJECT_CHANGE,
@ -76,9 +75,6 @@ ReducerRegistry.register(
case P2P_STATUS_CHANGED: case P2P_STATUS_CHANGED:
return _p2pStatusChanged(state, action); return _p2pStatusChanged(state, action);
case SET_DESKTOP_SHARING_ENABLED:
return _setDesktopSharingEnabled(state, action);
case SET_FOLLOW_ME: case SET_FOLLOW_ME:
return set(state, 'followMeEnabled', action.enabled); return set(state, 'followMeEnabled', action.enabled);
@ -343,21 +339,6 @@ function _p2pStatusChanged(state, action) {
return set(state, 'p2p', action.p2p); 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. * Reduces a specific Redux action SET_PASSWORD of the feature base/conference.
* *

View File

@ -25,6 +25,7 @@ import {
IconShareDesktop, IconShareDesktop,
IconShareVideo IconShareVideo
} from '../../../base/icons'; } from '../../../base/icons';
import JitsiMeetJS from '../../../base/lib-jitsi-meet';
import { import {
getLocalParticipant, getLocalParticipant,
getParticipants, getParticipants,
@ -1403,7 +1404,7 @@ class Toolbox extends Component<Props, State> {
*/ */
function _mapStateToProps(state) { function _mapStateToProps(state) {
const { conference, locked } = state['features/base/conference']; const { conference, locked } = state['features/base/conference'];
let { desktopSharingEnabled } = state['features/base/conference']; let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
const { const {
callStatsID, callStatsID,
enableFeaturesBasedOnToken enableFeaturesBasedOnToken