fix a small get_history bug

main
june moretz 2023-05-08 00:25:39 -04:00
parent 57c89a6b31
commit 2b68db954c
1 changed files with 8 additions and 6 deletions

View File

@ -78,12 +78,14 @@ window.onload = () => {
if (!window.earliestMessage) window.earliestMessage = msg.id; if (!window.earliestMessage) window.earliestMessage = msg.id;
}); });
window.socket.on("get_history", (msg) => { window.socket.on("get_history", (msg) => {
window.earliestMessage = msg.messages[msg.messages.length - 1].id; if (msg.messages.length > 0) {
for (let message of msg.messages) { window.earliestMessage = msg.messages[msg.messages.length - 1].id;
const el = document.createElement("div"); for (let message of msg.messages) {
el.classList.add("message"); const el = document.createElement("div");
el.innerHTML = `<strong>${message.name}: </strong>${message.message}`; el.classList.add("message");
document.getElementById("messages").prepend(el); el.innerHTML = `<strong>${message.name}: </strong>${message.message}`;
document.getElementById("messages").prepend(el);
}
} }
if (!msg.more) document.getElementById("loadmore").classList.add("hidden"); if (!msg.more) document.getElementById("loadmore").classList.add("hidden");
}); });