first load auto scroll to bottom

main
Tycho Luyben 2023-03-19 07:34:13 +00:00
parent 1d0c334f22
commit d8a497eca1
1 changed files with 3 additions and 1 deletions

View File

@ -35,12 +35,14 @@ export default function ChatPage(props: any) {
const { id } = useParams(); const { id } = useParams();
const context = useAppContext(); const context = useAppContext();
let firstLoad = true;
useEffect(() => { useEffect(() => {
if (props.share || !context.currentChat.chatLoadedAt) { if (props.share || !context.currentChat.chatLoadedAt) {
return; return;
} }
const shouldScroll = (Date.now() - context.currentChat.chatLoadedAt) > 5000; const shouldScroll = (Date.now() - context.currentChat.chatLoadedAt) > 5000 || firstLoad;
firstLoad = false;
if (!shouldScroll) { if (!shouldScroll) {
return; return;