Skip to content

Commit 6fcc749

Browse files
authored
Merge pull request cogentapps#60 from tluyben/firstload-autoscroll2
first load auto scroll to bottom
2 parents 109f2fc + d8a497e commit 6fcc749

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: app/src/components/pages/chat.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ export default function ChatPage(props: any) {
3535
const { id } = useParams();
3636
const context = useAppContext();
3737

38+
let firstLoad = true;
3839
useEffect(() => {
3940
if (props.share || !context.currentChat.chatLoadedAt) {
4041
return;
4142
}
4243

43-
const shouldScroll = (Date.now() - context.currentChat.chatLoadedAt) > 5000;
44+
const shouldScroll = (Date.now() - context.currentChat.chatLoadedAt) > 5000 || firstLoad;
45+
firstLoad = false;
4446

4547
if (!shouldScroll) {
4648
return;

0 commit comments

Comments
 (0)