more chance to see picture on user card
This commit is contained in:
		
							parent
							
								
									99dff44fd1
								
							
						
					
					
						commit
						23e8b81aa7
					
				| @ -1,4 +1,4 @@ | ||||
| import React from 'react' | ||||
| import React, { useMemo } from 'react' | ||||
| import { sha256 } from 'js-sha256' | ||||
| import { useState, useEffect, useRef } from 'react' | ||||
| import { Box, useColorMode, Text } from '@chakra-ui/react' | ||||
| @ -19,7 +19,7 @@ const REACTION_EMOJIS = { | ||||
|   clap: '👏' | ||||
| } | ||||
| 
 | ||||
| export function getGravatarURL(email, user) { | ||||
| export function getGravatarURL(email) { | ||||
|   if (!email) return void 0 | ||||
|   const address = String(email).trim().toLowerCase() | ||||
|   const hash = sha256(address) | ||||
| @ -49,6 +49,8 @@ export const UserCard = ({ | ||||
|   const [imageError, setImageError] = useState(false); | ||||
|   const [showReaction, setShowReaction] = useState(false); | ||||
|   const timeoutRef = useRef<NodeJS.Timeout | null>(null); | ||||
| 
 | ||||
|   const randomGravatarPath = useMemo(() => Math.random() * 1000, []) | ||||
|    | ||||
|   // Обрабатываем изменение реакции
 | ||||
|   useEffect(() => { | ||||
| @ -83,7 +85,7 @@ export const UserCard = ({ | ||||
|       position="relative" | ||||
|     > | ||||
|       <Avatar  | ||||
|         src={imageError ? getGravatarURL(student.email, null) : (student.picture || getGravatarURL(student.email, null))}  | ||||
|         src={imageError ? getGravatarURL(student.email || randomGravatarPath) : (student.picture || getGravatarURL(student.email))}  | ||||
|         onError={() => { | ||||
|           if (!imageError && student.picture) { | ||||
|             setImageError(true); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user