fix chat scroll behaviour
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user