don't duplicate previous messages if they already exist (reconnects)
modified: templates/chat.html
This commit is contained in:
parent
9c3bbe169f
commit
65e904b286
1 changed files with 6 additions and 0 deletions
|
|
@ -315,6 +315,12 @@ socket.on("message", (data) => {
|
|||
|
||||
// Socket event for receiving previous messages
|
||||
socket.on("previous_messages", (data) => {
|
||||
|
||||
if (document.getElementById("message-" + data.id)) {
|
||||
// If it exists, skip appending it
|
||||
return;
|
||||
}
|
||||
|
||||
const messageWrapper = document.createElement("div");
|
||||
messageWrapper.className = "message-wrapper";
|
||||
messageWrapper.id = "message-" + data.id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue