Bladeren bron

feat(config): Add useHostPageLocalStorage

master
Hristo Terezov 4 jaren geleden
bovenliggende
commit
8f06866646
3 gewijzigde bestanden met toevoegingen van 37 en 2 verwijderingen
  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 Bestand weergeven

@@ -666,6 +666,11 @@ var config = {
666 666
     // Sets the conference subject
667 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 674
     // List of undocumented settings used in jitsi-meet
670 675
     /**
671 676
      _immediateReloadThreshold

+ 1
- 0
react/features/base/config/configWhitelist.js Bestand weergeven

@@ -157,6 +157,7 @@ export default [
157 157
     'stereo',
158 158
     'subject',
159 159
     'testing',
160
+    'useHostPageLocalStorage',
160 161
     'useTurnUdp',
161 162
     'videoQuality.persist',
162 163
     'webrtcIceTcpDisable',

+ 31
- 2
react/features/base/jitsi-local-storage/setup.web.js Bestand weergeven

@@ -8,6 +8,7 @@ import { parseURLParams } from '../util/parseURLParams';
8 8
 import logger from './logger';
9 9
 
10 10
 declare var APP: Object;
11
+declare var config: Object;
11 12
 
12 13
 /**
13 14
  * Handles changes of the fake local storage.
@@ -18,15 +19,43 @@ function onFakeLocalStorageChanged() {
18 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 51
  * Performs initial setup of the jitsiLocalStorage.
23 52
  *
24 53
  * @returns {void}
25 54
  */
26 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 59
         try {
31 60
             const localStorageContent = JSON.parse(urlParams['appData.localStorageContent']);
32 61
 

Laden…
Annuleren
Opslaan