瀏覽代碼

feat(config): Add useHostPageLocalStorage

master
Hristo Terezov 4 年之前
父節點
當前提交
8f06866646
共有 3 個檔案被更改,包括 37 行新增2 行删除
  1. 5
    0
      config.js
  2. 1
    0
      react/features/base/config/configWhitelist.js
  3. 31
    2
      react/features/base/jitsi-local-storage/setup.web.js

+ 5
- 0
config.js 查看文件

666
     // Sets the conference subject
666
     // Sets the conference subject
667
     // subject: 'Conference Subject',
667
     // subject: 'Conference Subject',
668
 
668
 
669
+    // This property is related to the use case when jitsi-meet is used via the IFrame API. When the property is true
670
+    // jitsi-meet will use the local storage of the host page instead of its own. This option is useful if the browser
671
+    // is not persisting the local storage inside the iframe.
672
+    // useHostPageLocalStorage: true,
673
+
669
     // List of undocumented settings used in jitsi-meet
674
     // List of undocumented settings used in jitsi-meet
670
     /**
675
     /**
671
      _immediateReloadThreshold
676
      _immediateReloadThreshold

+ 1
- 0
react/features/base/config/configWhitelist.js 查看文件

157
     'stereo',
157
     'stereo',
158
     'subject',
158
     'subject',
159
     'testing',
159
     'testing',
160
+    'useHostPageLocalStorage',
160
     'useTurnUdp',
161
     'useTurnUdp',
161
     'videoQuality.persist',
162
     'videoQuality.persist',
162
     'webrtcIceTcpDisable',
163
     'webrtcIceTcpDisable',

+ 31
- 2
react/features/base/jitsi-local-storage/setup.web.js 查看文件

8
 import logger from './logger';
8
 import logger from './logger';
9
 
9
 
10
 declare var APP: Object;
10
 declare var APP: Object;
11
+declare var config: Object;
11
 
12
 
12
 /**
13
 /**
13
  * Handles changes of the fake local storage.
14
  * Handles changes of the fake local storage.
18
     APP.API.notifyLocalStorageChanged(jitsiLocalStorage.serialize());
19
     APP.API.notifyLocalStorageChanged(jitsiLocalStorage.serialize());
19
 }
20
 }
20
 
21
 
22
+/**
23
+ * Checks if the local storage of the host page needs to be used instead jitsi-meet's local storage.
24
+ *
25
+ * @param {Object} urlParams - Object with parsed URL params.
26
+ * @returns {boolean} - True if the local storage of the host page needs to be used instead jitsi-meet's local storage
27
+ * and false otherwise.
28
+ */
29
+function shouldUseHostPageLocalStorage(urlParams) {
30
+    // NOTE: normally the url params and the config will be merged into the redux store. But we want to setup the local
31
+    // storage as soon as possible, the store is not created yet and the merging of the URL params and the config
32
+    // haven't been executed yet. That's why we need to manually parse the URL params and also access the config trough
33
+    // the global variable.
34
+    if (urlParams['config.useHostPageLocalStorage'] === true
35
+        || (typeof config === 'object' && config.useHostPageLocalStorage)) {
36
+        return true;
37
+    }
38
+
39
+    if (jitsiLocalStorage.isLocalStorageDisabled()) { // We have detected that ou own local storage is not working.
40
+        return true;
41
+    }
42
+
43
+    if (browser.isWebKitBased()) { // Webkit browsers don't persist local storage for third-party iframes.
44
+        return true;
45
+    }
46
+
47
+    return false;
48
+}
49
+
21
 /**
50
 /**
22
  * Performs initial setup of the jitsiLocalStorage.
51
  * Performs initial setup of the jitsiLocalStorage.
23
  *
52
  *
24
  * @returns {void}
53
  * @returns {void}
25
  */
54
  */
26
 function setupJitsiLocalStorage() {
55
 function setupJitsiLocalStorage() {
27
-    if (jitsiLocalStorage.isLocalStorageDisabled() || browser.isWebKitBased()) {
28
-        const urlParams = parseURLParams(window.location);
56
+    const urlParams = parseURLParams(window.location);
29
 
57
 
58
+    if (shouldUseHostPageLocalStorage(urlParams)) {
30
         try {
59
         try {
31
             const localStorageContent = JSON.parse(urlParams['appData.localStorageContent']);
60
             const localStorageContent = JSON.parse(urlParams['appData.localStorageContent']);
32
 
61
 

Loading…
取消
儲存