Browse Source

feat(external-storage): Support.

dev1
Hristo Terezov 4 years ago
parent
commit
b881ccbcc7
5 changed files with 31 additions and 18 deletions
  1. 2
    0
      JitsiMeetJS.js
  2. 1
    0
      doc/API.md
  3. 23
    7
      modules/settings/Settings.js
  4. 4
    10
      package-lock.json
  5. 1
    1
      package.json

+ 2
- 0
JitsiMeetJS.js View File

24
 import ProxyConnectionService
24
 import ProxyConnectionService
25
     from './modules/proxyconnection/ProxyConnectionService';
25
     from './modules/proxyconnection/ProxyConnectionService';
26
 import recordingConstants from './modules/recording/recordingConstants';
26
 import recordingConstants from './modules/recording/recordingConstants';
27
+import Settings from './modules/settings/Settings';
27
 import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
28
 import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
28
 import precallTest from './modules/statistics/PrecallTest';
29
 import precallTest from './modules/statistics/PrecallTest';
29
 import Statistics from './modules/statistics/statistics';
30
 import Statistics from './modules/statistics/statistics';
175
     mediaDevices: JitsiMediaDevices,
176
     mediaDevices: JitsiMediaDevices,
176
     analytics: Statistics.analytics,
177
     analytics: Statistics.analytics,
177
     init(options = {}) {
178
     init(options = {}) {
179
+        Settings.init(options.externalStorage);
178
         Statistics.init(options);
180
         Statistics.init(options);
179
 
181
 
180
         // Initialize global window.connectionTimes
182
         // Initialize global window.connectionTimes

+ 1
- 0
doc/API.md View File

44
     - `enableWindowOnErrorHandler` - boolean property (default false). Enables/disables attaching global onerror handler (window.onerror).
44
     - `enableWindowOnErrorHandler` - boolean property (default false). Enables/disables attaching global onerror handler (window.onerror).
45
     - `disableThirdPartyRequests` - if true - callstats will be disabled and the callstats API won't be included.
45
     - `disableThirdPartyRequests` - if true - callstats will be disabled and the callstats API won't be included.
46
     - `enableAnalyticsLogging` - boolean property (default false). Enables/disables analytics logging.
46
     - `enableAnalyticsLogging` - boolean property (default false). Enables/disables analytics logging.
47
+    - `externalStorage` - Object that implements the Storage interface. If specified this object will be used for storing data instead of `localStorage`.
47
     - `callStatsCustomScriptUrl` - (optional) custom url to access callstats client script
48
     - `callStatsCustomScriptUrl` - (optional) custom url to access callstats client script
48
     - `disableRtx` - (optional) boolean property (default to false).  Enables/disable the use of RTX.
49
     - `disableRtx` - (optional) boolean property (default to false).  Enables/disable the use of RTX.
49
     - `disableH264` - (optional) boolean property (default to false).  If enabled, strips the H.264 codec from the local SDP.
50
     - `disableH264` - (optional) boolean property (default to false).  If enabled, strips the H.264 codec from the local SDP.

+ 23
- 7
modules/settings/Settings.js View File

13
  *
13
  *
14
  */
14
  */
15
 export default {
15
 export default {
16
+
17
+    /**
18
+     * The storage used to store the settings.
19
+     */
20
+    _storage: jitsiLocalStorage,
21
+
22
+    /**
23
+     * Initializes the Settings class.
24
+     *
25
+     * @param {Storage|undefined} externalStorage - Object that implements the Storage interface. This object will be
26
+     * used for storing data instead of jitsiLocalStorage if specified.
27
+     */
28
+    init(externalStorage) {
29
+        this._storage = externalStorage || jitsiLocalStorage;
30
+    },
31
+
16
     /**
32
     /**
17
      * Returns fake username for callstats
33
      * Returns fake username for callstats
18
      * @returns {string} fake username for callstats
34
      * @returns {string} fake username for callstats
19
      */
35
      */
20
     get callStatsUserName() {
36
     get callStatsUserName() {
21
         if (!_callStatsUserName) {
37
         if (!_callStatsUserName) {
22
-            _callStatsUserName = jitsiLocalStorage.getItem('callStatsUserName');
38
+            _callStatsUserName = this._storage.getItem('callStatsUserName');
23
             if (!_callStatsUserName) {
39
             if (!_callStatsUserName) {
24
                 _callStatsUserName = generateCallStatsUserName();
40
                 _callStatsUserName = generateCallStatsUserName();
25
-                jitsiLocalStorage.setItem('callStatsUserName', _callStatsUserName);
41
+                this._storage.setItem('callStatsUserName', _callStatsUserName);
26
             }
42
             }
27
         }
43
         }
28
 
44
 
35
      */
51
      */
36
     get machineId() {
52
     get machineId() {
37
         if (!_machineId) {
53
         if (!_machineId) {
38
-            _machineId = jitsiLocalStorage.getItem('jitsiMeetId');
54
+            _machineId = this._storage.getItem('jitsiMeetId');
39
             if (!_machineId) {
55
             if (!_machineId) {
40
                 _machineId = generateJitsiMeetId();
56
                 _machineId = generateJitsiMeetId();
41
-                jitsiLocalStorage.setItem('jitsiMeetId', _machineId);
57
+                this._storage.setItem('jitsiMeetId', _machineId);
42
             }
58
             }
43
         }
59
         }
44
 
60
 
52
     get sessionId() {
68
     get sessionId() {
53
         // We may update sessionId in localStorage from another JitsiConference
69
         // We may update sessionId in localStorage from another JitsiConference
54
         // instance and that's why we should always re-read it.
70
         // instance and that's why we should always re-read it.
55
-        return jitsiLocalStorage.getItem('sessionId');
71
+        return this._storage.getItem('sessionId');
56
     },
72
     },
57
 
73
 
58
     /**
74
     /**
61
      */
77
      */
62
     set sessionId(sessionId) {
78
     set sessionId(sessionId) {
63
         if (sessionId) {
79
         if (sessionId) {
64
-            jitsiLocalStorage.setItem('sessionId', sessionId);
80
+            this._storage.setItem('sessionId', sessionId);
65
         } else {
81
         } else {
66
-            jitsiLocalStorage.removeItem('sessionId');
82
+            this._storage.removeItem('sessionId');
67
         }
83
         }
68
     }
84
     }
69
 };
85
 };

+ 4
- 10
package-lock.json View File

1305
       }
1305
       }
1306
     },
1306
     },
1307
     "@jitsi/js-utils": {
1307
     "@jitsi/js-utils": {
1308
-      "version": "1.0.0",
1309
-      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.0.tgz",
1310
-      "integrity": "sha512-at9GPMP7IL0v6QS1Gs9c5MbbiN2AT0uKzsgKM8qS2wqXxqvpfT3p4U3+LH2IUyXiHlkmvlBMcNM02MltBdyRmQ==",
1308
+      "version": "1.0.2",
1309
+      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.2.tgz",
1310
+      "integrity": "sha512-ls+X9tn9EemUQwPEBr7Z0UD4sjRtwcu1Bh4MUo0Hv4arp0KVzcCYCW+mofsvuZvHg8xJX12LLNVgUKi1X5XTGg==",
1311
       "requires": {
1311
       "requires": {
1312
         "bowser": "2.7.0",
1312
         "bowser": "2.7.0",
1313
-        "js-md5": "0.7.3",
1314
-        "postis": "2.2.0"
1313
+        "js-md5": "0.7.3"
1315
       }
1314
       }
1316
     },
1315
     },
1317
     "@jitsi/sdp-interop": {
1316
     "@jitsi/sdp-interop": {
6486
       "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=",
6485
       "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=",
6487
       "dev": true
6486
       "dev": true
6488
     },
6487
     },
6489
-    "postis": {
6490
-      "version": "2.2.0",
6491
-      "resolved": "https://registry.npmjs.org/postis/-/postis-2.2.0.tgz",
6492
-      "integrity": "sha1-3F4yN2WYXd/cv9r8MUGpVprvdak="
6493
-    },
6494
     "prelude-ls": {
6488
     "prelude-ls": {
6495
       "version": "1.1.2",
6489
       "version": "1.1.2",
6496
       "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
6490
       "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",

+ 1
- 1
package.json View File

16
   "author": "",
16
   "author": "",
17
   "readmeFilename": "README.md",
17
   "readmeFilename": "README.md",
18
   "dependencies": {
18
   "dependencies": {
19
-    "@jitsi/js-utils": "1.0.0",
19
+    "@jitsi/js-utils": "1.0.2",
20
     "@jitsi/sdp-interop": "1.0.3",
20
     "@jitsi/sdp-interop": "1.0.3",
21
     "@jitsi/sdp-simulcast": "0.3.0",
21
     "@jitsi/sdp-simulcast": "0.3.0",
22
     "async": "0.9.0",
22
     "async": "0.9.0",

Loading…
Cancel
Save