From 36b7c435f55b869fb2a318ea938773ec917c7349 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Fri, 20 Feb 2026 22:36:18 +0800 Subject: [PATCH] fix: resolve chat current user from auth store instead of hardcoded participants[0] --- app/(order)/chat/[id]/page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/(order)/chat/[id]/page.tsx b/app/(order)/chat/[id]/page.tsx index 1793815..7361bcd 100644 --- a/app/(order)/chat/[id]/page.tsx +++ b/app/(order)/chat/[id]/page.tsx @@ -10,12 +10,14 @@ import { Input } from "@/components/ui/input" import { ScrollArea } from "@/components/ui/scroll-area" import { mockChatMessages, mockChatSessions } from "@/lib/mock-data" import { cn } from "@/lib/utils" +import { useAuthStore } from "@/store/auth" export default function ChatDetailPage({ params }: { params: Promise<{ id: string }> }) { const { id } = use(params) const session = mockChatSessions.find((s) => s.id === id) const messages = mockChatMessages.filter((m) => m.sessionId === id) const [input, setInput] = useState("") + const { user } = useAuthStore() if (!session) { return ( @@ -25,8 +27,8 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin ) } - const other = session.participants[1] - const currentUserId = session.participants[0].id + const currentUserId = user?.id ?? session.participants[0].id + const other = session.participants.find((p) => p.id !== currentUserId) ?? session.participants[1] return (