Add support for CLEARCHAT clearing the entire chat

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

@ -1593,12 +1593,19 @@ 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") {
if (chatMessage.message.params.length > 1) {
const removedSender = chatMessage.message.params[1]; const removedSender = chatMessage.message.params[1];
for (const childNode of document.getElementById("chat-replay").children) { for (const childNode of document.getElementById("chat-replay").children) {
if (childNode.dataset.sender === removedSender) { if (childNode.dataset.sender === removedSender) {
childNode.classList.add("chat-replay-message-cleared"); 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");
}
}
} else if (chatMessage.message.command === "USERNOTICE") { } else if (chatMessage.message.command === "USERNOTICE") {
const chatDOMList = renderSystemMessages(chatMessage); const chatDOMList = renderSystemMessages(chatMessage);
for (const chatDOM of chatDOMList) { for (const chatDOM of chatDOMList) {

@ -320,12 +320,18 @@ 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") {
if (chatMessage.message.params.length > 1) {
const removedSender = chatMessage.message.params[1]; const removedSender = chatMessage.message.params[1];
for (const messageElem of chatReplayContainer.children) { for (const messageElem of chatReplayContainer.children) {
if (messageElem.dataset.sender === removedSender) { if (messageElem.dataset.sender === removedSender) {
messageElem.classList.add("chat-replay-message-cleared"); messageElem.classList.add("chat-replay-message-cleared");
} }
} }
} else {
for (const messageElem of chatReplayContainer.children) {
messageElem.classList.add("chat-replay-message-cleared");
}
}
} else if (chatMessage.message.command === "USERNOTICE") { } else if (chatMessage.message.command === "USERNOTICE") {
const chatDOMList = renderSystemMessages(chatMessage); const chatDOMList = renderSystemMessages(chatMessage);
for (const chatDOM of chatDOMList) { for (const chatDOM of chatDOMList) {

Loading…
Cancel
Save