refactor(client): remove avatarType, add auth effects, simplify UserAvatar
This commit is contained in:
@@ -7,20 +7,19 @@ import { DEFAULT_STYLE_ID, getStyleById } from '@/shared/lib/avatar-styles'
|
||||
type UserAvatarProps = {
|
||||
userId: string
|
||||
avatarUrl?: string | null
|
||||
avatarType?: string | null
|
||||
avatarStyle?: string | null
|
||||
size?: number
|
||||
sx?: SxProps<Theme>
|
||||
}
|
||||
|
||||
export function UserAvatar({ userId, avatarUrl, avatarType, avatarStyle, size = 40, sx }: UserAvatarProps) {
|
||||
export function UserAvatar({ userId, avatarUrl, avatarStyle, size = 40, sx }: UserAvatarProps) {
|
||||
const generatedSrc = useMemo(() => {
|
||||
const styleDef = getStyleById(avatarStyle || DEFAULT_STYLE_ID)
|
||||
const avatar = createAvatar(styleDef.style, { seed: userId })
|
||||
return avatar.toDataUri()
|
||||
}, [userId, avatarStyle])
|
||||
|
||||
const src = avatarType && avatarUrl ? avatarUrl : generatedSrc
|
||||
const src = avatarUrl || generatedSrc
|
||||
|
||||
return (
|
||||
<Avatar src={src} sx={{ width: size, height: size, bgcolor: 'primary.main', ...sx }}>
|
||||
|
||||
Reference in New Issue
Block a user