refactor(auth): unify current user state usage across UI
This commit is contained in:
@@ -28,8 +28,8 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
|
||||
)
|
||||
}
|
||||
|
||||
const currentUserId = user?.id ?? session.participants[0].id
|
||||
const other = session.participants.find((p) => p.id !== currentUserId) ?? session.participants[1]
|
||||
const userId = user?.id ?? session.participants[0].id
|
||||
const other = session.participants.find((p) => p.id !== userId) ?? session.participants[1]
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-[calc(100vh-3.5rem)]">
|
||||
@@ -69,7 +69,7 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const isMine = msg.senderId === currentUserId
|
||||
const isMine = msg.senderId === userId
|
||||
return (
|
||||
<div key={msg.id} className={cn("flex gap-2", isMine && "flex-row-reverse")}>
|
||||
<Avatar className="h-8 w-8 shrink-0">
|
||||
@@ -107,13 +107,11 @@ export default function ChatDetailPage({ params }: { params: Promise<{ id: strin
|
||||
const text = input.trim()
|
||||
if (!text) return
|
||||
|
||||
const sender = session.participants.find(
|
||||
(participant) => participant.id === currentUserId,
|
||||
)
|
||||
const sender = session.participants.find((participant) => participant.id === userId)
|
||||
sendTextMessage(
|
||||
session.id,
|
||||
{
|
||||
id: currentUserId,
|
||||
id: userId,
|
||||
name: sender?.name ?? user?.nickname ?? "",
|
||||
avatar: sender?.avatar ?? user?.avatar ?? "",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user