Pārlūkot izejas kodu

fix(settings): do not use non-set localStorage values (#4299)

If a value is not set in localStorage then null is
returned. null should not be converted to an empty
string (via _.escape) because that will then be
stored in localStorage as the user set preference
and will keep overriding any other values set
in localStorage for the displayname.
j8
virtuacoplenny 5 gadus atpakaļ
vecāks
revīzija
eb644987ce
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 14 papildinājumiem un 4 dzēšanām
  1. 14
    4
      react/features/base/settings/reducer.js

+ 14
- 4
react/features/base/settings/reducer.js Parādīt failu

@@ -119,12 +119,22 @@ function _initSettings(featureState) {
119 119
     let settings = featureState;
120 120
 
121 121
     // Old Settings.js values
122
-    // FIXME: Let's remove this after a predefined time (e.g. by July 2018) to
123
-    // avoid garbage in the source.
124
-    const displayName = _.escape(window.localStorage.getItem('displayname'));
125
-    const email = _.escape(window.localStorage.getItem('email'));
122
+    // FIXME: jibri uses old settings.js local storage values to set its display
123
+    // name and email. Provide another way for jibri to set these values, update
124
+    // jibri, and remove the old settings.js values.
125
+    const savedDisplayName = window.localStorage.getItem('displayname');
126
+    const savedEmail = window.localStorage.getItem('email');
126 127
     let avatarID = _.escape(window.localStorage.getItem('avatarId'));
127 128
 
129
+    // The helper _.escape will convert null to an empty strings. The empty
130
+    // string will be saved in settings. On app re-load, because an empty string
131
+    // is a defined value, it will override any value found in local storage.
132
+    // The workaround is sidestepping _.escape when the value is not set in
133
+    // local storage.
134
+    const displayName
135
+        = savedDisplayName === null ? undefined : _.escape(savedDisplayName);
136
+    const email = savedEmail === null ? undefined : _.escape(savedEmail);
137
+
128 138
     if (!avatarID) {
129 139
         // if there is no avatar id, we generate a unique one and use it forever
130 140
         avatarID = randomHexString(32);

Notiek ielāde…
Atcelt
Saglabāt