From 2dbf778e564437c33f1738cd27aa11f363e23b21 Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Fri, 6 Jul 2018 22:09:09 +0200
Subject: [PATCH] Change the new DM limit behavior b/c older DMs don't load
 when scrolled to bottom

---
 Resources/Scripts/code.js | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js
index 8b6a16c6..2c28ffb5 100644
--- a/Resources/Scripts/code.js
+++ b/Resources/Scripts/code.js
@@ -1427,10 +1427,20 @@
   }
   
   //
-  // Block: Decrease amount of loaded DMs to avoid massive lag from re-opening them several times.
+  // Block: Limit amount of loaded DMs to avoid massive lag from re-opening them several times.
   //
-  if (ensurePropertyExists(TD, "services", "TwitterConversation", "CONVERSATION_ENTRY_COUNT")){
-    TD.services.TwitterConversation.CONVERSATION_ENTRY_COUNT = 20;
+  if (ensurePropertyExists(TD, "services", "TwitterConversation", "prototype", "renderThread")){
+    const prevFunc = TD.services.TwitterConversation.prototype.renderThread;
+    
+    TD.services.TwitterConversation.prototype.renderThread = function(){
+      let prevMessages = this.messages;
+
+      this.messages = prevMessages.slice(0, 100);
+      let result = prevFunc.apply(this, arguments);
+      this.messages = prevMessages;
+
+      return result;
+    };
   }
   
   //