From a6ba61079fc34946753f1a72b3b95f9422bb493b Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 9 Oct 2021 20:59:45 -0700 Subject: [PATCH] Cap the number of renderable messages to increase performance --- webroot/js/components/chat/chat.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webroot/js/components/chat/chat.js b/webroot/js/components/chat/chat.js index 169dfb321..97afc7fb6 100644 --- a/webroot/js/components/chat/chat.js +++ b/webroot/js/components/chat/chat.js @@ -212,6 +212,9 @@ export default class Chat extends Component { ); }); updatedMessageList.splice(insertAtIndex + 1, 0, convertedMessage); + if (updatedMessageList.length > 300) { + updatedMessageList = updatedMessageList.slice(Math.max(updatedMessageList.length - 300, 0)); + } this.setState({ messages: updatedMessageList, });