diff --git a/lib/shared/avatar-utils.js b/lib/shared/avatar-utils.js --- a/lib/shared/avatar-utils.js +++ b/lib/shared/avatar-utils.js @@ -34,6 +34,15 @@ { color: selectedThreadColors[8], emoji: '🏀', type: 'emoji' }, ]; +function getDefaultAvatar(hashKey: string, color?: string): ClientEmojiAvatar { + const avatarIndex = stringHash(hashKey) % defaultEmojiAvatars.length; + + return { + ...defaultEmojiAvatars[avatarIndex], + color: color ? color : defaultEmojiAvatars[avatarIndex].color, + }; +} + function getAvatarForUser( user: ?{ +avatar?: ?ClientAvatar, +username?: ?string, ... }, ): ClientAvatar { @@ -45,8 +54,7 @@ return defaultAnonymousUserEmojiAvatar; } - const avatarIndex = stringHash(user.username) % defaultEmojiAvatars.length; - return defaultEmojiAvatars[avatarIndex]; + return getDefaultAvatar(user.username); } export { getAvatarForUser };