👤 fix: Use user?.username if user?.name is undefined (#2511)

* Use `user?.username` if `user?.name` is undefined

* Add useLocalize hook to Icon component
This commit is contained in:
ilsubyeega 2024-04-25 01:34:01 +09:00 committed by GitHub
parent 75da75be08
commit 667f5f91fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -14,6 +14,7 @@ import {
} from '~/components/svg';
import { useAuthContext } from '~/hooks/AuthContext';
import useAvatar from '~/hooks/Messages/useAvatar';
import useLocalize from '~/hooks/useLocalize';
import { IconProps } from '~/common';
import { cn } from '~/utils';
@ -31,9 +32,10 @@ const Icon: React.FC<IconProps> = (props) => {
} = props;
const avatarSrc = useAvatar(user);
const localize = useLocalize();
if (isCreatedByUser) {
const username = user?.name || 'User';
const username = user?.name || user?.username || localize('com_nav_user');
return (
<div