Skip to content

Commit

Permalink
Merge pull request cogentapps#60 from tluyben/firstload-autoscroll2
Browse files Browse the repository at this point in the history
first load auto scroll to bottom
  • Loading branch information
cogentapps authored Apr 12, 2023
2 parents 109f2fc + d8a497e commit 6fcc749
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 6fcc749

Please sign in to comment.