Merge pull request #60 from tluyben/firstload-autoscroll2

first load auto scroll to bottom
This commit is contained in:
Cogent Apps
2023-04-12 02:38:17 -07:00
committed by GitHub

View File

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