+ ${showSender && !m.mine ? `
${escapeHtml(m.from)}
` : ''}
${escapeHtml(m.body)}
${formatChatTime(m.created_at)}${m.mine && m.seen ? ' ' : ''}
@@ -932,18 +964,20 @@ async function loadChatHistory(peer, quiet = false) {
container.scrollTop = container.scrollHeight;
}
- // Refresh thread list to clear unread badges
if (!quiet) loadChatThreads(true);
}
async function sendChatMessage() {
const input = $('chat-input');
- if (!input || !chatActivePeer) return;
+ if (!input || !chatActive) return;
const body = input.value.trim();
if (!body) return;
input.value = '';
- await api('api/chat/send', { method: 'POST', body: { body, recipient: chatActivePeer } });
- loadChatHistory(chatActivePeer);
+ const payload = chatActive.kind === 'room'
+ ? { body, room_uid: chatActive.roomUid }
+ : { body, recipient: chatActive.peer };
+ await api('api/chat/send', { method: 'POST', body: payload });
+ loadChatHistory(chatActive);
loadChatThreads(true);
}