ソースを参照

feat(Avatar): simplified code

j8
Saúl Ibarra Corretgé 6年前
コミット
f5a667ad9e
1個のファイルの変更6行の追加17行の削除
  1. 6
    17
      react/features/base/participants/components/Avatar.native.js

+ 6
- 17
react/features/base/participants/components/Avatar.native.js ファイルの表示

@@ -186,31 +186,20 @@ export default class Avatar extends Component<Props, State> {
186 186
      */
187 187
     _getBackgroundColor({ uri }) {
188 188
         if (!uri) {
189
-            // @lyubomir: I'm leaving @saghul's implementation which picks up a
190
-            // random color bellow so that we have it in the source code in
191
-            // case we decide to use it in the future. However, I think at the
192
-            // time of this writing that the randomness reduces the
193
-            // predictability which React is supposed to bring to our app.
194 189
             return ColorPalette.white;
195 190
         }
196 191
 
197 192
         let hash = 0;
198 193
 
199
-        if (typeof uri === 'string') {
200
-            /* eslint-disable no-bitwise */
194
+        /* eslint-disable no-bitwise */
201 195
 
202
-            for (let i = 0; i < uri.length; i++) {
203
-                hash = uri.charCodeAt(i) + ((hash << 5) - hash);
204
-                hash |= 0; // Convert to 32-bit integer
205
-            }
206
-
207
-            /* eslint-enable no-bitwise */
208
-        } else {
209
-            // @saghul: If we have no URI yet, we have no data to hash from. So
210
-            // use a random value.
211
-            hash = Math.floor(Math.random() * 360);
196
+        for (let i = 0; i < uri.length; i++) {
197
+            hash = uri.charCodeAt(i) + ((hash << 5) - hash);
198
+            hash |= 0; // Convert to 32-bit integer
212 199
         }
213 200
 
201
+        /* eslint-enable no-bitwise */
202
+
214 203
         return `hsl(${hash % 360}, 100%, 75%)`;
215 204
     }
216 205
 

読み込み中…
キャンセル
保存