浏览代码

feat(Avatar): simplified code

master
Saúl Ibarra Corretgé 7 年前
父节点
当前提交
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
      */
186
      */
187
     _getBackgroundColor({ uri }) {
187
     _getBackgroundColor({ uri }) {
188
         if (!uri) {
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
             return ColorPalette.white;
189
             return ColorPalette.white;
195
         }
190
         }
196
 
191
 
197
         let hash = 0;
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
         return `hsl(${hash % 360}, 100%, 75%)`;
203
         return `hsl(${hash % 360}, 100%, 75%)`;
215
     }
204
     }
216
 
205
 

正在加载...
取消
保存