Browse Source

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.
master
Saúl Ibarra Corretgé 4 years ago
parent
commit
2a01d3550c

+ 0
- 7
ConferenceEvents.js View File

@@ -2,10 +2,3 @@
2 2
  * Notifies interested parties that hangup procedure will start.
3 3
  */
4 4
 export const BEFORE_HANGUP = 'conference.before_hangup';
5
-
6
-/**
7
- * Notifies interested parties that desktop sharing enable/disable state is
8
- * changed.
9
- */
10
-export const DESKTOP_SHARING_ENABLED_CHANGED
11
-    = 'conference.desktop_sharing_enabled_changed';

+ 4
- 23
conference.js View File

@@ -41,8 +41,7 @@ import {
41 41
     lockStateChanged,
42 42
     onStartMutedPolicyChanged,
43 43
     p2pStatusChanged,
44
-    sendLocalParticipant,
45
-    setDesktopSharingEnabled
44
+    sendLocalParticipant
46 45
 } from './react/features/base/conference';
47 46
 import {
48 47
     checkAndNotifyForNewDevice,
@@ -441,17 +440,8 @@ export default {
441 440
      * the tracks won't exist).
442 441
      */
443 442
     _localTracksInitialized: false,
444
-    isSharingScreen: false,
445 443
 
446
-    /**
447
-     * Indicates if the desktop sharing functionality has been enabled.
448
-     * It takes into consideration the status returned by
449
-     * {@link JitsiMeetJS.isDesktopSharingEnabled()}. The latter can be false
450
-     * either if the desktop sharing is not supported by the current browser
451
-     * or if it was disabled through lib-jitsi-meet specific options (check
452
-     * config.js for listed options).
453
-     */
454
-    isDesktopSharingEnabled: false,
444
+    isSharingScreen: false,
455 445
 
456 446
     /**
457 447
      * The local audio track (if any).
@@ -679,14 +669,6 @@ export default {
679 669
         con.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _connectionFailedHandler);
680 670
         APP.connection = connection = con;
681 671
 
682
-        // Desktop sharing related stuff:
683
-        this.isDesktopSharingEnabled
684
-            = JitsiMeetJS.isDesktopSharingEnabled();
685
-        eventEmitter.emit(JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED, this.isDesktopSharingEnabled);
686
-
687
-        APP.store.dispatch(
688
-            setDesktopSharingEnabled(this.isDesktopSharingEnabled));
689
-
690 672
         this._createRoom(tracks);
691 673
         APP.remoteControl.init();
692 674
 
@@ -1532,9 +1514,8 @@ export default {
1532 1514
         if (this.videoSwitchInProgress) {
1533 1515
             return Promise.reject('Switch in progress.');
1534 1516
         }
1535
-        if (!this.isDesktopSharingEnabled) {
1536
-            return Promise.reject(
1537
-                'Cannot toggle screen sharing: not supported.');
1517
+        if (!JitsiMeetJS.isDesktopSharingEnabled()) {
1518
+            return Promise.reject('Cannot toggle screen sharing: not supported.');
1538 1519
         }
1539 1520
 
1540 1521
         if (this.isAudioOnly()) {

+ 5
- 36
modules/API/API.js View File

@@ -2,7 +2,6 @@
2 2
 
3 3
 import Logger from 'jitsi-meet-logger';
4 4
 
5
-import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
6 5
 import {
7 6
     createApiEvent,
8 7
     sendAnalytics
@@ -14,7 +13,7 @@ import {
14 13
     setSubject
15 14
 } from '../../react/features/base/conference';
16 15
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
17
-import { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
16
+import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
18 17
 import { pinParticipant } from '../../react/features/base/participants';
19 18
 import {
20 19
     processExternalDeviceRequest
@@ -46,14 +45,6 @@ declare var APP: Object;
46 45
  */
47 46
 let commands = {};
48 47
 
49
-/**
50
- * The state of screen sharing(started/stopped) before the screen sharing is
51
- * enabled and initialized.
52
- * NOTE: This flag help us to cache the state and use it if toggle-share-screen
53
- * was received before the initialization.
54
- */
55
-let initialScreenSharingState = false;
56
-
57 48
 /**
58 49
  * The transport instance used for communication with external apps.
59 50
  *
@@ -430,19 +421,6 @@ function initCommands() {
430 421
     });
431 422
 }
432 423
 
433
-/**
434
- * Listens for desktop/screen sharing enabled events and toggles the screen
435
- * sharing if needed.
436
- *
437
- * @param {boolean} enabled - Current screen sharing enabled status.
438
- * @returns {void}
439
- */
440
-function onDesktopSharingEnabledChanged(enabled = false) {
441
-    if (enabled && initialScreenSharingState) {
442
-        toggleScreenSharing();
443
-    }
444
-}
445
-
446 424
 /**
447 425
  * Check whether the API should be enabled or not.
448 426
  *
@@ -470,12 +448,10 @@ function shouldBeEnabled() {
470 448
  * @returns {void}
471 449
  */
472 450
 function toggleScreenSharing(enable) {
473
-    if (APP.conference.isDesktopSharingEnabled) {
474
-
475
-        // eslint-disable-next-line no-empty-function
476
-        APP.conference.toggleScreenSharing(enable).catch(() => {});
477
-    } else {
478
-        initialScreenSharingState = !initialScreenSharingState;
451
+    if (JitsiMeetJS.isDesktopSharingEnabled()) {
452
+        APP.conference.toggleScreenSharing(enable).catch(() => {
453
+            logger.warn('Failed to toggle screen-sharing');
454
+        });
479 455
     }
480 456
 }
481 457
 
@@ -508,10 +484,6 @@ class API {
508 484
          */
509 485
         this._enabled = true;
510 486
 
511
-        APP.conference.addListener(
512
-            JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
513
-            onDesktopSharingEnabledChanged);
514
-
515 487
         initCommands();
516 488
     }
517 489
 
@@ -1058,9 +1030,6 @@ class API {
1058 1030
     dispose() {
1059 1031
         if (this._enabled) {
1060 1032
             this._enabled = false;
1061
-            APP.conference.removeListener(
1062
-                JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
1063
-                onDesktopSharingEnabledChanged);
1064 1033
         }
1065 1034
     }
1066 1035
 }

+ 2
- 3
modules/remotecontrol/RemoteControl.js View File

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

+ 0
- 12
react/features/base/conference/actionTypes.js View File

@@ -140,18 +140,6 @@ export const P2P_STATUS_CHANGED = 'P2P_STATUS_CHANGED';
140 140
  */
141 141
 export const SEND_TONES = 'SEND_TONES';
142 142
 
143
-/**
144
- * The type of (redux) action which sets the desktop sharing enabled flag for
145
- * the current conference.
146
- *
147
- * {
148
- *     type: SET_DESKTOP_SHARING_ENABLED,
149
- *     desktopSharingEnabled: boolean
150
- * }
151
- */
152
-export const SET_DESKTOP_SHARING_ENABLED
153
-    = 'SET_DESKTOP_SHARING_ENABLED';
154
-
155 143
 /**
156 144
  * The type of (redux) action which updates the current known status of the
157 145
  * Follow Me feature.

+ 0
- 17
react/features/base/conference/actions.js View File

@@ -43,7 +43,6 @@ import {
43 43
     LOCK_STATE_CHANGED,
44 44
     P2P_STATUS_CHANGED,
45 45
     SEND_TONES,
46
-    SET_DESKTOP_SHARING_ENABLED,
47 46
     SET_FOLLOW_ME,
48 47
     SET_PASSWORD,
49 48
     SET_PASSWORD_FAILED,
@@ -573,22 +572,6 @@ export function sendTones(tones: string, duration: number, pause: number) {
573 572
     };
574 573
 }
575 574
 
576
-/**
577
- * Sets the flag for indicating if desktop sharing is enabled.
578
- *
579
- * @param {boolean} desktopSharingEnabled - True if desktop sharing is enabled.
580
- * @returns {{
581
- *     type: SET_DESKTOP_SHARING_ENABLED,
582
- *     desktopSharingEnabled: boolean
583
- * }}
584
- */
585
-export function setDesktopSharingEnabled(desktopSharingEnabled: boolean) {
586
-    return {
587
-        type: SET_DESKTOP_SHARING_ENABLED,
588
-        desktopSharingEnabled
589
-    };
590
-}
591
-
592 575
 /**
593 576
  * Enables or disables the Follow Me feature.
594 577
  *

+ 0
- 19
react/features/base/conference/reducer.js View File

@@ -16,7 +16,6 @@ import {
16 16
     CONFERENCE_WILL_LEAVE,
17 17
     LOCK_STATE_CHANGED,
18 18
     P2P_STATUS_CHANGED,
19
-    SET_DESKTOP_SHARING_ENABLED,
20 19
     SET_FOLLOW_ME,
21 20
     SET_PASSWORD,
22 21
     SET_PENDING_SUBJECT_CHANGE,
@@ -76,9 +75,6 @@ ReducerRegistry.register(
76 75
         case P2P_STATUS_CHANGED:
77 76
             return _p2pStatusChanged(state, action);
78 77
 
79
-        case SET_DESKTOP_SHARING_ENABLED:
80
-            return _setDesktopSharingEnabled(state, action);
81
-
82 78
         case SET_FOLLOW_ME:
83 79
             return set(state, 'followMeEnabled', action.enabled);
84 80
 
@@ -343,21 +339,6 @@ function _p2pStatusChanged(state, action) {
343 339
     return set(state, 'p2p', action.p2p);
344 340
 }
345 341
 
346
-/**
347
- * Reduces a specific Redux action SET_DESKTOP_SHARING_ENABLED of the feature
348
- * base/conference.
349
- *
350
- * @param {Object} state - The Redux state of the feature base/conference.
351
- * @param {Action} action - The Redux action SET_DESKTOP_SHARING_ENABLED to
352
- * reduce.
353
- * @private
354
- * @returns {Object} The new state of the feature base/conference after the
355
- * reduction of the specified action.
356
- */
357
-function _setDesktopSharingEnabled(state, action) {
358
-    return set(state, 'desktopSharingEnabled', action.desktopSharingEnabled);
359
-}
360
-
361 342
 /**
362 343
  * Reduces a specific Redux action SET_PASSWORD of the feature base/conference.
363 344
  *

+ 2
- 1
react/features/toolbox/components/web/Toolbox.js View File

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

Loading…
Cancel
Save