Add support for CLEARCHAT clearing the entire chat

pull/317/head
ElementalAlchemist 2 years ago committed by Mike Lang
parent 832a0264bb
commit 0cad481cea

@ -1593,9 +1593,16 @@ function renderChatLog() {
removedMessageElem.classList.add("chat-replay-message-cleared"); removedMessageElem.classList.add("chat-replay-message-cleared");
} }
} else if (chatMessage.message.command === "CLEARCHAT") { } else if (chatMessage.message.command === "CLEARCHAT") {
const removedSender = chatMessage.message.params[1]; if (chatMessage.message.params.length > 1) {
for (const childNode of document.getElementById("chat-replay").children) { const removedSender = chatMessage.message.params[1];
if (childNode.dataset.sender === removedSender) { for (const childNode of document.getElementById("chat-replay").children) {
if (childNode.dataset.sender === removedSender) {
childNode.classList.add("chat-replay-message-cleared");
}
}
} else {
// Without a target parameter, the CLEARCHAT clears all messages in the entire chat.
for (const childNode of document.getElementById("chat-replay").children) {
childNode.classList.add("chat-replay-message-cleared"); childNode.classList.add("chat-replay-message-cleared");
} }
} }

@ -320,9 +320,15 @@ function handleChatMessage(chatReplayContainer, chatMessage) {
targetMessageElem.classList.add("chat-replay-message-cleared"); targetMessageElem.classList.add("chat-replay-message-cleared");
} }
} else if (chatMessage.message.command === "CLEARCHAT") { } else if (chatMessage.message.command === "CLEARCHAT") {
const removedSender = chatMessage.message.params[1]; if (chatMessage.message.params.length > 1) {
for (const messageElem of chatReplayContainer.children) { const removedSender = chatMessage.message.params[1];
if (messageElem.dataset.sender === removedSender) { for (const messageElem of chatReplayContainer.children) {
if (messageElem.dataset.sender === removedSender) {
messageElem.classList.add("chat-replay-message-cleared");
}
}
} else {
for (const messageElem of chatReplayContainer.children) {
messageElem.classList.add("chat-replay-message-cleared"); messageElem.classList.add("chat-replay-message-cleared");
} }
} }

Loading…
Cancel
Save