fix: resolve chat current user from auth store instead of hardcoded participants[0]

This commit is contained in:
zetaloop
2026-02-20 22:36:18 +08:00
parent b0e2728aa9
commit 36b7c435f5
+4 -2
View File
@@ -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 (
<div className="flex flex-col h-[calc(100vh-3.5rem)]">