Chat Widget, changes in nav bar

Auto Scroll chat and changes in Nav bar
This commit is contained in:
Nikitha
2026-04-15 08:12:16 -06:00
parent c5c5461167
commit 8e1ab89e6c
6 changed files with 106 additions and 31 deletions

View File

@@ -32,10 +32,16 @@ function ChatPage() {
}
}, [authLoading, user, router, conversationIdParam]);
useEffect(() => {
const prevMsgLengthRef = useRef(0);
useEffect(() => {
if (messages.length > prevMsgLengthRef.current) {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
}
prevMsgLengthRef.current = messages.length;
}, [messages]);
const fetchMessages = useCallback(async (convId) => {
if (!token || !convId) return;
try {