|
@@ -1,26 +1,6 @@
|
1
|
1
|
/* global JitsiMeetJS */
|
2
|
|
-
|
3
|
2
|
import UIUtil from '../UI/util/UIUtil';
|
4
|
|
-
|
5
|
|
-let email = '';
|
6
|
|
-let avatarId = '';
|
7
|
|
-let displayName = '';
|
8
|
|
-let language = null;
|
9
|
|
-let cameraDeviceId = '';
|
10
|
|
-let micDeviceId = '';
|
11
|
|
-let welcomePageDisabled = false;
|
12
|
|
-let localFlipX = null;
|
13
|
|
-let avatarUrl = '';
|
14
|
|
-
|
15
|
|
-function supportsLocalStorage() {
|
16
|
|
- try {
|
17
|
|
- return 'localStorage' in window && window.localStorage !== null;
|
18
|
|
- } catch (e) {
|
19
|
|
- console.log("localstorage is not supported");
|
20
|
|
- return false;
|
21
|
|
- }
|
22
|
|
-}
|
23
|
|
-
|
|
3
|
+import jitsiLocalStorage from '../util/JitsiLocalStorage';
|
24
|
4
|
|
25
|
5
|
function generateUniqueId() {
|
26
|
6
|
function _p8() {
|
|
@@ -29,45 +9,43 @@ function generateUniqueId() {
|
29
|
9
|
return _p8() + _p8() + _p8() + _p8();
|
30
|
10
|
}
|
31
|
11
|
|
32
|
|
-if (supportsLocalStorage()) {
|
33
|
|
- if (!window.localStorage.jitsiMeetId) {
|
34
|
|
- window.localStorage.jitsiMeetId = generateUniqueId();
|
35
|
|
- console.log("generated id", window.localStorage.jitsiMeetId);
|
36
|
|
- }
|
|
12
|
+if (!jitsiLocalStorage.getItem("jitsiMeetId")) {
|
|
13
|
+ jitsiLocalStorage.setItem("jitsiMeetId",generateUniqueId());
|
|
14
|
+ console.log("generated id", jitsiLocalStorage.getItem("jitsiMeetId"));
|
|
15
|
+}
|
37
|
16
|
|
38
|
|
- email = UIUtil.unescapeHtml(window.localStorage.email || '');
|
39
|
|
- avatarId = UIUtil.unescapeHtml(window.localStorage.avatarId || '');
|
40
|
|
- if (!avatarId) {
|
41
|
|
- // if there is no avatar id, we generate a unique one and use it forever
|
42
|
|
- avatarId = generateUniqueId();
|
43
|
|
- window.localStorage.avatarId = avatarId;
|
44
|
|
- }
|
|
17
|
+let avatarUrl = '';
|
45
|
18
|
|
46
|
|
- localFlipX = JSON.parse(window.localStorage.localFlipX || true);
|
47
|
|
- displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
|
48
|
|
- language = window.localStorage.language;
|
49
|
|
- cameraDeviceId = window.localStorage.cameraDeviceId || '';
|
50
|
|
- micDeviceId = window.localStorage.micDeviceId || '';
|
51
|
|
- welcomePageDisabled = JSON.parse(
|
52
|
|
- window.localStorage.welcomePageDisabled || false
|
53
|
|
- );
|
54
|
|
-
|
55
|
|
- // Currently audio output device change is supported only in Chrome and
|
56
|
|
- // default output always has 'default' device ID
|
57
|
|
- var audioOutputDeviceId = window.localStorage.audioOutputDeviceId
|
58
|
|
- || 'default';
|
59
|
|
-
|
60
|
|
- if (audioOutputDeviceId !==
|
61
|
|
- JitsiMeetJS.mediaDevices.getAudioOutputDevice()) {
|
62
|
|
- JitsiMeetJS.mediaDevices.setAudioOutputDevice(audioOutputDeviceId)
|
63
|
|
- .catch((ex) => {
|
64
|
|
- console.warn('Failed to set audio output device from local ' +
|
65
|
|
- 'storage. Default audio output device will be used' +
|
66
|
|
- 'instead.', ex);
|
67
|
|
- });
|
68
|
|
- }
|
69
|
|
-} else {
|
70
|
|
- console.log("local storage is not supported");
|
|
19
|
+let email = UIUtil.unescapeHtml(jitsiLocalStorage.getItem("email") || '');
|
|
20
|
+let avatarId = UIUtil.unescapeHtml(jitsiLocalStorage.getItem("avatarId") || '');
|
|
21
|
+if (!avatarId) {
|
|
22
|
+ // if there is no avatar id, we generate a unique one and use it forever
|
|
23
|
+ avatarId = generateUniqueId();
|
|
24
|
+ jitsiLocalStorage.setItem("avatarId", avatarId);
|
|
25
|
+}
|
|
26
|
+
|
|
27
|
+let localFlipX = JSON.parse(jitsiLocalStorage.getItem("localFlipX") || true);
|
|
28
|
+let displayName = UIUtil.unescapeHtml(
|
|
29
|
+ jitsiLocalStorage.getItem("displayname") || '');
|
|
30
|
+let language = jitsiLocalStorage.getItem("language");
|
|
31
|
+let cameraDeviceId = jitsiLocalStorage.getItem("cameraDeviceId") || '';
|
|
32
|
+let micDeviceId = jitsiLocalStorage.getItem("micDeviceId") || '';
|
|
33
|
+let welcomePageDisabled = JSON.parse(
|
|
34
|
+ jitsiLocalStorage.getItem("welcomePageDisabled") || false);
|
|
35
|
+
|
|
36
|
+// Currently audio output device change is supported only in Chrome and
|
|
37
|
+// default output always has 'default' device ID
|
|
38
|
+let audioOutputDeviceId = jitsiLocalStorage.getItem("audioOutputDeviceId")
|
|
39
|
+ || 'default';
|
|
40
|
+
|
|
41
|
+if (audioOutputDeviceId !==
|
|
42
|
+ JitsiMeetJS.mediaDevices.getAudioOutputDevice()) {
|
|
43
|
+ JitsiMeetJS.mediaDevices.setAudioOutputDevice(audioOutputDeviceId)
|
|
44
|
+ .catch((ex) => {
|
|
45
|
+ console.warn('Failed to set audio output device from local ' +
|
|
46
|
+ 'storage. Default audio output device will be used' +
|
|
47
|
+ 'instead.', ex);
|
|
48
|
+ });
|
71
|
49
|
}
|
72
|
50
|
|
73
|
51
|
export default {
|
|
@@ -82,7 +60,8 @@ export default {
|
82
|
60
|
displayName = newDisplayName;
|
83
|
61
|
|
84
|
62
|
if (!disableLocalStore)
|
85
|
|
- window.localStorage.displayname = UIUtil.escapeHtml(displayName);
|
|
63
|
+ jitsiLocalStorage.setItem("displayname",
|
|
64
|
+ UIUtil.escapeHtml(displayName));
|
86
|
65
|
},
|
87
|
66
|
|
88
|
67
|
/**
|
|
@@ -102,7 +81,7 @@ export default {
|
102
|
81
|
email = newEmail;
|
103
|
82
|
|
104
|
83
|
if (!disableLocalStore)
|
105
|
|
- window.localStorage.email = UIUtil.escapeHtml(newEmail);
|
|
84
|
+ jitsiLocalStorage.setItem("email", UIUtil.escapeHtml(newEmail));
|
106
|
85
|
},
|
107
|
86
|
|
108
|
87
|
/**
|
|
@@ -142,7 +121,7 @@ export default {
|
142
|
121
|
},
|
143
|
122
|
setLanguage: function (lang) {
|
144
|
123
|
language = lang;
|
145
|
|
- window.localStorage.language = lang;
|
|
124
|
+ jitsiLocalStorage.setItem("language", lang);
|
146
|
125
|
},
|
147
|
126
|
|
148
|
127
|
/**
|
|
@@ -151,7 +130,7 @@ export default {
|
151
|
130
|
*/
|
152
|
131
|
setLocalFlipX: function (val) {
|
153
|
132
|
localFlipX = val;
|
154
|
|
- window.localStorage.localFlipX = val;
|
|
133
|
+ jitsiLocalStorage.setItem("localFlipX", val);
|
155
|
134
|
},
|
156
|
135
|
|
157
|
136
|
/**
|
|
@@ -179,7 +158,7 @@ export default {
|
179
|
158
|
setCameraDeviceId: function (newId, store) {
|
180
|
159
|
cameraDeviceId = newId;
|
181
|
160
|
if (store)
|
182
|
|
- window.localStorage.cameraDeviceId = newId;
|
|
161
|
+ jitsiLocalStorage.setItem("cameraDeviceId", newId);
|
183
|
162
|
},
|
184
|
163
|
|
185
|
164
|
/**
|
|
@@ -199,7 +178,7 @@ export default {
|
199
|
178
|
setMicDeviceId: function (newId, store) {
|
200
|
179
|
micDeviceId = newId;
|
201
|
180
|
if (store)
|
202
|
|
- window.localStorage.micDeviceId = newId;
|
|
181
|
+ jitsiLocalStorage.setItem("micDeviceId", newId);
|
203
|
182
|
},
|
204
|
183
|
|
205
|
184
|
/**
|
|
@@ -218,7 +197,8 @@ export default {
|
218
|
197
|
*/
|
219
|
198
|
setAudioOutputDeviceId: function (newId = 'default') {
|
220
|
199
|
return JitsiMeetJS.mediaDevices.setAudioOutputDevice(newId)
|
221
|
|
- .then(() => window.localStorage.audioOutputDeviceId = newId);
|
|
200
|
+ .then(() =>
|
|
201
|
+ jitsiLocalStorage.setItem("audioOutputDeviceId", newId));
|
222
|
202
|
},
|
223
|
203
|
|
224
|
204
|
/**
|
|
@@ -235,6 +215,6 @@ export default {
|
235
|
215
|
*/
|
236
|
216
|
setWelcomePageEnabled (enabled) {
|
237
|
217
|
welcomePageDisabled = !enabled;
|
238
|
|
- window.localStorage.welcomePageDisabled = welcomePageDisabled;
|
|
218
|
+ jitsiLocalStorage.setItem("welcomePageDisabled", welcomePageDisabled);
|
239
|
219
|
}
|
240
|
220
|
};
|