Sfoglia il codice sorgente

feat(api): allow for explicit screenshare state toggling

master
Leonard Kim 5 anni fa
parent
commit
bc403adb46
2 ha cambiato i file con 21 aggiunte e 5 eliminazioni
  1. 3
    1
      conference.js
  2. 18
    4
      modules/API/API.js

+ 3
- 1
conference.js Vedi File

@@ -1457,7 +1457,9 @@ export default {
1457 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 Vedi File

@@ -116,9 +116,19 @@ function initCommands() {
116 116
             sendAnalytics(createApiEvent('chat.toggled'));
117 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 130
             sendAnalytics(createApiEvent('screen.sharing.toggled'));
121
-            toggleScreenSharing();
131
+            toggleScreenSharing(options.enable);
122 132
         },
123 133
         'toggle-tile-view': () => {
124 134
             sendAnalytics(createApiEvent('tile-view.toggled'));
@@ -242,13 +252,17 @@ function shouldBeEnabled() {
242 252
 /**
243 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 259
  * @returns {void}
246 260
  */
247
-function toggleScreenSharing() {
261
+function toggleScreenSharing(enable) {
248 262
     if (APP.conference.isDesktopSharingEnabled) {
249 263
 
250 264
         // eslint-disable-next-line no-empty-function
251
-        APP.conference.toggleScreenSharing().catch(() => {});
265
+        APP.conference.toggleScreenSharing(enable).catch(() => {});
252 266
     } else {
253 267
         initialScreenSharingState = !initialScreenSharingState;
254 268
     }

Loading…
Annulla
Salva