Skip to content

Commit

Permalink
first load auto scroll to bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
tluyben committed Mar 19, 2023
1 parent 1d0c334 commit d8a497e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/components/pages/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d8a497e

Please sign in to comment.