Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(Avatar): simplified code

Saúl Ibarra Corretgéf5a667ad9eff
diff --git a/react/features/base/participants/components/Avatar.native.js b/react/features/base/participants/components/Avatar.native.js
index bbe8a88bad..1a1bc9a401 100644
--- a/react/features/base/participants/components/Avatar.native.js
+++ b/react/features/base/participants/components/Avatar.native.js
@@ -186,31 +186,20 @@ export default class Avatar extends Component<Props, State> {
*/
_getBackgroundColor({ uri }) {
if (!uri) {
- // @lyubomir: I'm leaving @saghul's implementation which picks up a
- // random color bellow so that we have it in the source code in
- // case we decide to use it in the future. However, I think at the
- // time of this writing that the randomness reduces the
- // predictability which React is supposed to bring to our app.
return ColorPalette.white;
}
let hash = 0;
- if (typeof uri === 'string') {
- /* eslint-disable no-bitwise */
+ /* eslint-disable no-bitwise */
- for (let i = 0; i < uri.length; i++) {
- hash = uri.charCodeAt(i) + ((hash << 5) - hash);
- hash |= 0; // Convert to 32-bit integer
- }
-
- /* eslint-enable no-bitwise */
- } else {
- // @saghul: If we have no URI yet, we have no data to hash from. So
- // use a random value.
- hash = Math.floor(Math.random() * 360);
+ for (let i = 0; i < uri.length; i++) {
+ hash = uri.charCodeAt(i) + ((hash << 5) - hash);
+ hash |= 0; // Convert to 32-bit integer
}
+ /* eslint-enable no-bitwise */
+
return `hsl(${hash % 360}, 100%, 75%)`;
}