Always scroll to the bottom for now
parent
693457a393
commit
34a515ca1f
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "chat",
|
"name": "chat",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -93,15 +93,11 @@ export function ChatMessage({
|
||||||
|
|
||||||
export function ChatMessageList() {
|
export function ChatMessageList() {
|
||||||
const { messages } = useChat();
|
const { messages } = useChat();
|
||||||
const scrolledOnce = useRef(false);
|
|
||||||
const messageWrapper = useRef<HTMLDivElement>(null);
|
const messageWrapper = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (messages.length > 0 && !scrolledOnce.current) {
|
messageWrapper.current.scrollTop = messageWrapper.current.scrollHeight;
|
||||||
scrolledOnce.current = true;
|
}, [messages]);
|
||||||
messageWrapper.current.scrollTop = messageWrapper.current?.scrollHeight;
|
|
||||||
}
|
|
||||||
}, [messages])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ChatMessageList" ref={messageWrapper}>
|
<div className="ChatMessageList" ref={messageWrapper}>
|
||||||
|
|
|
@ -36,8 +36,8 @@ set CACHE_VER = {
|
||||||
'js/lozad.js': 4000,
|
'js/lozad.js': 4000,
|
||||||
'js/sort_table.js': 4001,
|
'js/sort_table.js': 4001,
|
||||||
|
|
||||||
'css/chat_done.css': 1005,
|
'css/chat_done.css': 1006,
|
||||||
'js/chat_done.js': 1005,
|
'js/chat_done.js': 1006,
|
||||||
}
|
}
|
||||||
-%}
|
-%}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue