From 116e16e30dfda4ffd9aea5e006d78db525a323d3 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Tue, 2 May 2023 02:52:25 +0800 Subject: [PATCH] fixup --- app/components/chat.tsx | 1 + app/components/markdown.tsx | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index bd2c913d..4aaa8437 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -725,6 +725,7 @@ export function Chat() { }} fontSize={fontSize} parentRef={scrollRef} + defaultShow={i >= messages.length - 10} /> {!isUser && !message.preview && ( diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index eefb31f3..b5805e50 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -62,11 +62,12 @@ export function Markdown( loading?: boolean; fontSize?: number; parentRef: RefObject; + defaultShow?: boolean; } & React.DOMAttributes, ) { const mdRef = useRef(null); const renderedHeight = useRef(0); - const inView = useRef(false); + const inView = useRef(!!props.defaultShow); const parent = props.parentRef.current; const md = mdRef.current; @@ -90,15 +91,6 @@ export function Markdown( } }; - useEffect(() => { - setTimeout(() => { - if (!inView.current) { - checkInView(); - } - }, 30); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - checkInView(); return (