Merge pull request #60 from tluyben/firstload-autoscroll2
first load auto scroll to bottom
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user