From be498e8f9385488a451e5f26e6059e991690203f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taavi=20V=C3=A4=C3=A4n=C3=A4nen?= Date: Fri, 31 Dec 2021 23:24:29 +0200 Subject: [PATCH] Count number of mode changes, not MODE messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the code in MessageCondensed that generates the condensed messages ("X users have joined, Y modes were set") to count the number of actual mode changes instead of the raw count of MODE messages. One mode message can contain multiple mode changes. Signed-off-by: Taavi Väänänen --- client/components/MessageCondensed.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/components/MessageCondensed.vue b/client/components/MessageCondensed.vue index 279fd8b1..d167a86d 100644 --- a/client/components/MessageCondensed.vue +++ b/client/components/MessageCondensed.vue @@ -46,7 +46,19 @@ export default { }); for (const message of this.messages) { - obj[message.type]++; + // special case since one MODE message can change multiple modes + if (message.type === "mode") { + // syntax: +vv-t maybe-some targets + // we want the number of mode changes in the message, so count the + // number of chars other than + and - before the first space + const modeChangesCount = message.text + .split(" ")[0] + .split("") + .filter((char) => char !== "+" && char !== "-").length; + obj[message.type] += modeChangesCount; + } else { + obj[message.type]++; + } } // Count quits as parts in condensed messages to reduce information density