mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
👤 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:
parent
75da75be08
commit
667f5f91fe
3 changed files with 5 additions and 3 deletions
|
|
@ -42,7 +42,7 @@ export default function Message(props: TMessageProps) {
|
||||||
|
|
||||||
let messageLabel = '';
|
let messageLabel = '';
|
||||||
if (isCreatedByUser) {
|
if (isCreatedByUser) {
|
||||||
messageLabel = UsernameDisplay ? user?.name : localize('com_user_message');
|
messageLabel = UsernameDisplay ? user?.name || user?.username : localize('com_user_message');
|
||||||
} else {
|
} else {
|
||||||
messageLabel = message.sender;
|
messageLabel = message.sender;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import {
|
||||||
} from '~/components/svg';
|
} from '~/components/svg';
|
||||||
import { useAuthContext } from '~/hooks/AuthContext';
|
import { useAuthContext } from '~/hooks/AuthContext';
|
||||||
import useAvatar from '~/hooks/Messages/useAvatar';
|
import useAvatar from '~/hooks/Messages/useAvatar';
|
||||||
|
import useLocalize from '~/hooks/useLocalize';
|
||||||
import { IconProps } from '~/common';
|
import { IconProps } from '~/common';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
|
|
||||||
|
|
@ -31,9 +32,10 @@ const Icon: React.FC<IconProps> = (props) => {
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const avatarSrc = useAvatar(user);
|
const avatarSrc = useAvatar(user);
|
||||||
|
const localize = useLocalize();
|
||||||
|
|
||||||
if (isCreatedByUser) {
|
if (isCreatedByUser) {
|
||||||
const username = user?.name || 'User';
|
const username = user?.name || user?.username || localize('com_nav_user');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ function NavLinks() {
|
||||||
className="mt-2 grow overflow-hidden text-ellipsis whitespace-nowrap text-left text-black dark:text-white"
|
className="mt-2 grow overflow-hidden text-ellipsis whitespace-nowrap text-left text-black dark:text-white"
|
||||||
style={{ marginTop: '0', marginLeft: '0' }}
|
style={{ marginTop: '0', marginLeft: '0' }}
|
||||||
>
|
>
|
||||||
{user?.name || localize('com_nav_user')}
|
{user?.name || user?.username || localize('com_nav_user')}
|
||||||
</div>
|
</div>
|
||||||
</Menu.Button>
|
</Menu.Button>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue