From 50f8606ba814f394eb6881ef82ddcbd1f651c8dc Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Wed, 15 Apr 2026 08:07:17 -0600 Subject: [PATCH] fix chat scroll jumps and move about us to home page --- web/app/ai-chat/page.js | 5 +++++ web/app/chat/page.js | 5 +++++ web/app/page.js | 29 ++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/web/app/ai-chat/page.js b/web/app/ai-chat/page.js index 4e7ff875..8bfe0bb8 100644 --- a/web/app/ai-chat/page.js +++ b/web/app/ai-chat/page.js @@ -30,6 +30,7 @@ function AiChatPage() { const pollRef = useRef(null); const lastMessageIdRef = useRef(null); const fileInputRef = useRef(null); + const lastScrolledIdRef = useRef(null); useEffect(() => { if (!authLoading && !user) { @@ -38,6 +39,10 @@ function AiChatPage() { }, [authLoading, user, router, conversationIdParam]); useEffect(() => { + if (messages.length === 0) return; + const lastMsg = messages[messages.length - 1]; + if (lastMsg.id === lastScrolledIdRef.current) return; + lastScrolledIdRef.current = lastMsg.id; const area = messagesAreaRef.current; if (!area) return; const nearBottom = area.scrollHeight - area.scrollTop - area.clientHeight < 150; diff --git a/web/app/chat/page.js b/web/app/chat/page.js index 74a2834e..20ed7f41 100644 --- a/web/app/chat/page.js +++ b/web/app/chat/page.js @@ -30,6 +30,7 @@ function ChatPage() { const pollRef = useRef(null); const lastMessageIdRef = useRef(null); const fileInputRef = useRef(null); + const lastScrolledIdRef = useRef(null); useEffect(() => { if (!authLoading && !user) { @@ -38,6 +39,10 @@ function ChatPage() { }, [authLoading, user, router, conversationIdParam]); useEffect(() => { + if (messages.length === 0) return; + const lastMsg = messages[messages.length - 1]; + if (lastMsg.id === lastScrolledIdRef.current) return; + lastScrolledIdRef.current = lastMsg.id; const area = messagesAreaRef.current; if (!area) return; const nearBottom = area.scrollHeight - area.scrollTop - area.clientHeight < 150; diff --git a/web/app/page.js b/web/app/page.js index 91f71946..8b928be1 100644 --- a/web/app/page.js +++ b/web/app/page.js @@ -15,7 +15,6 @@ const navImages = [ {id: "nav-adopt", src: "/images/home/navimages/adopt.jpg", alt: "Adopt a Pet", link: "/adopt", title: "Adopt a Pet"}, {id: "nav-products", src: "/images/home/navimages/store.jpg", alt: "Online Store", link: "/products", title: "Online Store"}, {id: "nav-appointments", src: "/images/home/navimages/appointments.jpg", alt: "Appointments", link: "/appointments", title: "Appointments"}, - {id: "nav-about", src: "/images/home/navimages/about.jpg", alt: "About Us", link: "/about", title: "About Us"}, ]; export default function Home() { @@ -76,6 +75,34 @@ export default function Home() { ))} + + {/* About Us */} +
+
+

About Leon's Pet Store

+

Your trusted local destination for pet care, adoption, and supplies — built on a love for animals and community.

+
+
+
+
+

What We Do

+

Leon's Pet Store is a full-service pet shop offering adoptions, grooming, veterinary appointments, and a wide range of supplies to keep your pets happy and healthy.

+
+
+

Our Focus

+
    +
  • Support responsible pet adoption
  • +
  • Provide grooming and care services
  • +
  • Offer reliable pet supplies
  • +
  • Create a friendly customer experience
  • +
+
+
+

Visit the Store

+

Come visit us in person or explore our services online. Whether you're a first-time pet owner or a seasoned animal lover, we're here to help every step of the way.

+
+
+
); }