From d8a497eca188b045cc4fdf9e5e51e1057e06c20a Mon Sep 17 00:00:00 2001
From: Tycho Luyben <tycho@e-lab.nl>
Date: Sun, 19 Mar 2023 07:34:13 +0000
Subject: [PATCH] first load auto scroll to bottom

---
 app/src/components/pages/chat.tsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/app/src/components/pages/chat.tsx b/app/src/components/pages/chat.tsx
index 4f93fcc..3c776e3 100644
--- a/app/src/components/pages/chat.tsx
+++ b/app/src/components/pages/chat.tsx
@@ -35,12 +35,14 @@ export default function ChatPage(props: any) {
     const { id } = useParams();
     const context = useAppContext();
 
+    let firstLoad = true;
     useEffect(() => {
         if (props.share || !context.currentChat.chatLoadedAt) {
             return;
         }
 
-        const shouldScroll = (Date.now() - context.currentChat.chatLoadedAt) > 5000;
+        const shouldScroll = (Date.now() - context.currentChat.chatLoadedAt) > 5000 || firstLoad;
+        firstLoad = false;
 
         if (!shouldScroll) {
             return;