Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: slove commnuity user avatarUrl is wrong, should update others in profile (#11634)

Shinji-Li04465c810516
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx
index d1915c27079..c6549fe3d81 100644
--- a/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx
@@ -4,7 +4,7 @@ import { SiGithub, SiX } from '@icons-pack/react-simple-icons';
import { ActionIcon, Avatar, Button, Flexbox, Text, Tooltip, TooltipGroup } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { Globe } from 'lucide-react';
-import { memo } from 'react';
+import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useUserDetailContext } from '../DetailProvider';
@@ -19,12 +19,31 @@ const UserHeader = memo(() => {
const displayName = user.displayName || user.userName || user.namespace;
const username = user.userName || user.namespace;
+ // Normalize avatar URL - convert relative paths to absolute URLs
+ const avatarUrl = useMemo(() => {
+ if (!user.avatarUrl) return undefined;
+ // If it's a relative path (starts with /), prepend the origin
+ if (user.avatarUrl.startsWith('/')) {
+ return `${window.location.origin}${user.avatarUrl}`;
+ }
+ return user.avatarUrl;
+ }, [user.avatarUrl]);
+
+ const bannerUrl = useMemo(() => {
+ if (!user.bannerUrl) return null;
+ // If it's a relative path (starts with /), prepend the origin
+ if (user.bannerUrl.startsWith('/')) {
+ return `${window.location.origin}${user.bannerUrl}`;
+ }
+ return user.bannerUrl;
+ }, [user.bannerUrl]);
+
return (
<>
- <Banner avatar={user?.avatarUrl} bannerUrl={user?.bannerUrl} />
+ <Banner avatar={avatarUrl} bannerUrl={bannerUrl} />
<Flexbox gap={16}>
<Avatar
- avatar={user.avatarUrl || undefined}
+ avatar={avatarUrl}
shape={'square'}
size={64}
style={{ boxShadow: `0 0 0 4px ${cssVar.colorBgContainer}`, flexShrink: 0 }}
diff --git a/src/app/[variants]/(main)/community/(detail)/user/index.tsx b/src/app/[variants]/(main)/community/(detail)/user/index.tsx
index 78833d09092..8a082cb7b61 100644
--- a/src/app/[variants]/(main)/community/(detail)/user/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/user/index.tsx
@@ -46,6 +46,9 @@ const UserDetailPage = memo<UserDetailPageProps>(({ mobile }) => {
// Call the original onSuccess callback if provided
onSuccess?.(profile);
+ // Refresh page data to show updated profile
+ mutate();
+
// Navigate to new URL if userName changed
const newUserName = profile.userName || profile.namespace;
if (newUserName && newUserName !== currentUserName) {
@@ -53,7 +56,7 @@ const UserDetailPage = memo<UserDetailPageProps>(({ mobile }) => {
}
});
},
- [data?.user?.userName, data?.user?.namespace, openProfileSetup, navigate],
+ [data?.user?.userName, data?.user?.namespace, openProfileSetup, navigate, mutate],
);
const contextConfig = useMemo(() => {