Attempt to fix the message history for the webclient and REST API.

This commit is contained in:
Charles Descamps 2025-03-28 18:42:57 -07:00
parent 8a1728f083
commit 2c02fde8c5
2 changed files with 10 additions and 5 deletions

View file

@ -235,10 +235,15 @@
chatDiv.innerHTML = ""; // Clear the chat history
// Fetch message history for the new chat room
fetch(`/get_history?chat_room=${chatRoom}`)
.then(response => response.json())
fetch(`/get_history?chat_room=${encodeURIComponent(chatRoom)}`)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.messages) {
if (data.messages && data.messages.length > 0) {
data.messages.forEach(message => {
const messageElement = document.createElement('div');
messageElement.textContent = message;