Преглед изворни кода

feat(api): allow for explicit screenshare state toggling

master
Leonard Kim пре 5 година
родитељ
комит
bc403adb46
2 измењених фајлова са 21 додато и 5 уклоњено
  1. 3
    1
      conference.js
  2. 18
    4
      modules/API/API.js

+ 3
- 1
conference.js Прегледај датотеку

1457
             return this._switchToScreenSharing(options);
1457
             return this._switchToScreenSharing(options);
1458
         }
1458
         }
1459
 
1459
 
1460
-        return this._untoggleScreenSharing();
1460
+        return this._untoggleScreenSharing
1461
+            ? this._untoggleScreenSharing()
1462
+            : Promise.resolve();
1461
     },
1463
     },
1462
 
1464
 
1463
     /**
1465
     /**

+ 18
- 4
modules/API/API.js Прегледај датотеку

116
             sendAnalytics(createApiEvent('chat.toggled'));
116
             sendAnalytics(createApiEvent('chat.toggled'));
117
             APP.UI.toggleChat();
117
             APP.UI.toggleChat();
118
         },
118
         },
119
-        'toggle-share-screen': () => {
119
+
120
+        /**
121
+         * Callback to invoke when the "toggle-share-screen" command is received.
122
+         *
123
+         * @param {Object} options - Additional details of how to perform
124
+         * the action. Note this parameter is undocumented and experimental.
125
+         * @param {boolean} options.enable - Whether trying to enable screen
126
+         * sharing or to turn it off.
127
+         * @returns {void}
128
+         */
129
+        'toggle-share-screen': (options = {}) => {
120
             sendAnalytics(createApiEvent('screen.sharing.toggled'));
130
             sendAnalytics(createApiEvent('screen.sharing.toggled'));
121
-            toggleScreenSharing();
131
+            toggleScreenSharing(options.enable);
122
         },
132
         },
123
         'toggle-tile-view': () => {
133
         'toggle-tile-view': () => {
124
             sendAnalytics(createApiEvent('tile-view.toggled'));
134
             sendAnalytics(createApiEvent('tile-view.toggled'));
242
 /**
252
 /**
243
  * Executes on toggle-share-screen command.
253
  * Executes on toggle-share-screen command.
244
  *
254
  *
255
+ * @param {boolean} [enable] - Whether this toggle is to explicitly enable or
256
+ * disable screensharing. If not defined, the application will automatically
257
+ * attempt to toggle between enabled and disabled. This boolean is useful for
258
+ * explicitly setting desired screensharing state.
245
  * @returns {void}
259
  * @returns {void}
246
  */
260
  */
247
-function toggleScreenSharing() {
261
+function toggleScreenSharing(enable) {
248
     if (APP.conference.isDesktopSharingEnabled) {
262
     if (APP.conference.isDesktopSharingEnabled) {
249
 
263
 
250
         // eslint-disable-next-line no-empty-function
264
         // eslint-disable-next-line no-empty-function
251
-        APP.conference.toggleScreenSharing().catch(() => {});
265
+        APP.conference.toggleScreenSharing(enable).catch(() => {});
252
     } else {
266
     } else {
253
         initialScreenSharingState = !initialScreenSharingState;
267
         initialScreenSharingState = !initialScreenSharingState;
254
     }
268
     }

Loading…
Откажи
Сачувај