fix chat scroll behaviour

This commit is contained in:
2026-04-16 00:25:32 -06:00
parent c09309a47a
commit 8d8ba41edf
2 changed files with 6 additions and 16 deletions

View File

@@ -109,14 +109,9 @@ function ChatPage() {
lastScrolledIdRef.current = lastMsg.id;
const area = messagesAreaRef.current;
if (!area) return;
const isOwn = lastMsg.senderId === user?.id;
if (isOwn) {
area.scrollTop = area.scrollHeight;
} else {
const nearBottom = area.scrollHeight - area.scrollTop - area.clientHeight < 80;
if (nearBottom) area.scrollTop = area.scrollHeight;
}
}, [messages, user?.id]);
const nearBottom = area.scrollHeight - area.scrollTop - area.clientHeight < 150;
if (nearBottom) area.scrollTop = area.scrollHeight;
}, [messages]);
const fetchMessages = useCallback(async (convId) => {
if (!token || !convId) return;