fix: garbled text displayed on avatars (#6575)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
maruric 2023-05-14 02:49:09 +09:00 committed by GitHub
parent e0f2869374
commit 306e133651
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 28 deletions

View file

@ -1,7 +1,7 @@
import "./Avatar.scss";
import React, { useState } from "react";
import { getClientInitials } from "../clients";
import { getNameInitial } from "../clients";
type AvatarProps = {
onClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
@ -12,7 +12,7 @@ type AvatarProps = {
};
export const Avatar = ({ color, onClick, name, src }: AvatarProps) => {
const shortName = getClientInitials(name);
const shortName = getNameInitial(name);
const [error, setError] = useState(false);
const loadImg = !error && src;
const style = loadImg ? undefined : { background: color };