diff --git a/assets/chat/js/window.js b/assets/chat/js/window.js index 7c965b3b..4dcc8019 100644 --- a/assets/chat/js/window.js +++ b/assets/chat/js/window.js @@ -122,9 +122,26 @@ class ChatWindow extends EventEmitter { remove.forEach((element) => { element.remove(); }); - - this.messages = this.messages.slice(lines.length - this.maxlines); } + + let clientMessages = 0; + this.messages = this.messages + .reverse() + .filter((message, index) => { + if (clientOnlyMessages.includes(message.type)) { + clientMessages += 1; + // remove client only messages if above maxlines + if (index >= this.maxlines) { + return false; + } + // remove history message if above maxlines/maxhistory + the clientMessages + } else if (index >= Math.max(this.maxlines, 150) + clientMessages) { + return false; + } + + return true; + }) + .reverse(); } }