fix: correct WebSocket callback signature for chat messages

The WebSocket onmessage handler passes (message, payload) to callbacks,
where payload contains the actual message data. Updated handleChatMessage
to use the second parameter (payload) instead of first (message).

This fixes: Multi-user chat messages now properly received and displayed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-02-01 22:03:28 +05:30
parent f3044a29e8
commit 939225a610
1 changed files with 9 additions and 7 deletions

View File

@ -540,15 +540,17 @@ const JKSessionScreen = () => {
//@refreshCurrentSession(true);
// Chat message handler - receives messages from WebSocket and dispatches to Redux
const handleChatMessage = (data) => {
// Callback signature: (fullMessage, payload) where payload contains the chat_message data
const handleChatMessage = (fullMessage, payload) => {
// Transform Protocol Buffer format to Redux format
// payload contains: {sender_name, sender_id, msg, msg_id, created_at, channel, ...}
const message = {
id: data.msg_id,
senderId: data.sender_id,
senderName: data.sender_name,
message: data.msg,
createdAt: data.created_at,
channel: 'session',
id: payload.msg_id,
senderId: payload.sender_id,
senderName: payload.sender_name,
message: payload.msg,
createdAt: payload.created_at,
channel: payload.channel || 'session',
sessionId: currentSession.id
};
dispatch(addMessageFromWebSocket(message));