fix: resolve chat current user from auth store instead of hardcoded participants[0]
This commit is contained in:
@@ -10,12 +10,14 @@ import { Input } from "@/components/ui/input"
|
|||||||
import { ScrollArea } from "@/components/ui/scroll-area"
|
import { ScrollArea } from "@/components/ui/scroll-area"
|
||||||
import { mockChatMessages, mockChatSessions } from "@/lib/mock-data"
|
import { mockChatMessages, mockChatSessions } from "@/lib/mock-data"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
import { useAuthStore } from "@/store/auth"
|
||||||
|
|
||||||
export default function ChatDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
export default function ChatDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
||||||
const { id } = use(params)
|
const { id } = use(params)
|
||||||
const session = mockChatSessions.find((s) => s.id === id)
|
const session = mockChatSessions.find((s) => s.id === id)
|
||||||
const messages = mockChatMessages.filter((m) => m.sessionId === id)
|
const messages = mockChatMessages.filter((m) => m.sessionId === id)
|
||||||
const [input, setInput] = useState("")
|
const [input, setInput] = useState("")
|
||||||
|
const { user } = useAuthStore()
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return (
|
return (
|
||||||
@@ -25,8 +27,8 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const other = session.participants[1]
|
const currentUserId = user?.id ?? session.participants[0].id
|
||||||
const currentUserId = session.participants[0].id
|
const other = session.participants.find((p) => p.id !== currentUserId) ?? session.participants[1]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-[calc(100vh-3.5rem)]">
|
<div className="flex flex-col h-[calc(100vh-3.5rem)]">
|
||||||
|
|||||||
Reference in New Issue
Block a user