This commit is contained in:
Yidadaa 2023-05-02 02:52:25 +08:00
parent ae8050a3f7
commit 116e16e30d
2 changed files with 3 additions and 10 deletions

View File

@ -725,6 +725,7 @@ export function Chat() {
}}
fontSize={fontSize}
parentRef={scrollRef}
defaultShow={i >= messages.length - 10}
/>
</div>
{!isUser && !message.preview && (

View File

@ -62,11 +62,12 @@ export function Markdown(
loading?: boolean;
fontSize?: number;
parentRef: RefObject<HTMLDivElement>;
defaultShow?: boolean;
} & React.DOMAttributes<HTMLDivElement>,
) {
const mdRef = useRef<HTMLDivElement>(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 (