Updated history approach.
This commit is contained in:
@@ -56,19 +56,6 @@ export function initWebSocket(username, chatEl, inputContainer, usersListEl) {
|
||||
users.forEach(({ id, username }) => addUser(id, username));
|
||||
const groups = getGroupedUsers();
|
||||
usersListEl.innerHTML = "Online: " + groups.join(", ");
|
||||
// Replay chat history.
|
||||
const history = packet.data.history || [];
|
||||
history.forEach((raw) => {
|
||||
try {
|
||||
const histPkt = JSON.parse(raw);
|
||||
if (histPkt.type === "msg-event") {
|
||||
const { id, username: u, content, ts, parent } = histPkt.data;
|
||||
addMessage({ id, username: u, content, ts, parent });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Invalid history entry", raw);
|
||||
}
|
||||
});
|
||||
//addNotice(`<i>Users online: ${groups.join(", ")}</i>`);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user