Scroll to the bottom a single time

remotes/1693176582716663532/tmp_refs/heads/watchparty
Outrun Colors 2022-09-23 23:50:21 -05:00
parent aa4cbc173f
commit 693457a393
No known key found for this signature in database
GPG Key ID: 0426976DCEFE6073
3 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "chat",
"version": "0.0.5",
"version": "0.0.6",
"main": "index.js",
"license": "MIT",
"dependencies": {

View File

@ -93,8 +93,16 @@ export function ChatMessage({
export function ChatMessageList() {
const { messages } = useChat();
const scrolledOnce = useRef(false);
const messageWrapper = useRef<HTMLDivElement>(null);
useEffect(() => {
if (messages.length > 0 && !scrolledOnce.current) {
scrolledOnce.current = true;
messageWrapper.current.scrollTop = messageWrapper.current?.scrollHeight;
}
}, [messages])
return (
<div className="ChatMessageList" ref={messageWrapper}>
{messages.map((message, index) => (

View File

@ -36,8 +36,8 @@ set CACHE_VER = {
'js/lozad.js': 4000,
'js/sort_table.js': 4001,
'css/chat_done.css': 1004,
'js/chat_done.js': 1004,
'css/chat_done.css': 1005,
'js/chat_done.js': 1005,
}
-%}