瀏覽代碼

fix(pinning): dynamically check auto-pin setting

Any overrides set on interfaceConfig are not
applied on module load. As such, call to get
the value of the auto pin setting, providing
time for the bootstrapping to set overrides.
Otherwise iframe api users cannot override
the setting.
j8
Leonard Kim 5 年之前
父節點
當前提交
af2c61fd96
共有 1 個文件被更改,包括 18 次插入8 次删除
  1. 18
    8
      react/features/video-layout/subscriber.js

+ 18
- 8
react/features/video-layout/subscriber.js 查看文件

@@ -18,10 +18,6 @@ import { setParticipantsWithScreenShare } from './actions';
18 18
 declare var APP: Object;
19 19
 declare var interfaceConfig: Object;
20 20
 
21
-// TODO: interfaceConfig should be in redux so we didn't have to do this.
22
-const AUTO_PIN_LATEST_SCREEN_SHARE
23
-    = typeof interfaceConfig === 'object' ? interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE : 'remote-only';
24
-
25 21
 /**
26 22
  * StateListenerRegistry provides a reliable way of detecting changes to
27 23
  * preferred layout state and dispatching additional actions.
@@ -37,7 +33,7 @@ StateListenerRegistry.register(
37 33
             dispatch(
38 34
                 setMaxReceiverVideoQuality(VIDEO_QUALITY_LEVELS.HIGH));
39 35
 
40
-            if (AUTO_PIN_LATEST_SCREEN_SHARE) {
36
+            if (_getAutoPinSetting()) {
41 37
                 _updateAutoPinnedParticipant(store);
42 38
             }
43 39
         }
@@ -52,7 +48,7 @@ StateListenerRegistry.register(
52 48
 StateListenerRegistry.register(
53 49
     /* selector */ state => state['features/base/tracks'],
54 50
     /* listener */ debounce((tracks, store) => {
55
-        if (!AUTO_PIN_LATEST_SCREEN_SHARE) {
51
+        if (!_getAutoPinSetting()) {
56 52
             return;
57 53
         }
58 54
 
@@ -60,8 +56,7 @@ StateListenerRegistry.register(
60 56
             = store.getState()['features/video-layout'].screenShares || [];
61 57
         const knownSharingParticipantIds = tracks.reduce((acc, track) => {
62 58
             if (track.mediaType === 'video' && track.videoType === 'desktop') {
63
-                const skipTrack
64
-                    = AUTO_PIN_LATEST_SCREEN_SHARE === 'remote-only' && track.local;
59
+                const skipTrack = _getAutoPinSetting() === 'remote-only' && track.local;
65 60
 
66 61
                 if (!skipTrack) {
67 62
                     acc.push(track.participantId);
@@ -93,6 +88,21 @@ StateListenerRegistry.register(
93 88
         }
94 89
     }, 100));
95 90
 
91
+/**
92
+ * A selector for retrieving the current automatic pinning setting.
93
+ *
94
+ * @private
95
+ * @returns {string|undefined} The string "remote-only" is returned if only
96
+ * remote screensharing should be automatically pinned, any other truthy value
97
+ * means automatically pin all screenshares. Falsy means do not automatically
98
+ * pin any screenshares.
99
+ */
100
+function _getAutoPinSetting() {
101
+    return typeof interfaceConfig === 'object'
102
+        ? interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE
103
+        : 'remote-only';
104
+}
105
+
96 106
 /**
97 107
  * Private helper to automatically pin the latest screen share stream or unpin
98 108
  * if there are no more screen share streams.

Loading…
取消
儲存