first load auto scroll to bottom
parent
1d0c334f22
commit
d8a497eca1
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue