diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx index 2e46f1e869..1b8ef36d05 100644 --- a/web/app/components/base/chat/chat/index.tsx +++ b/web/app/components/base/chat/chat/index.tsx @@ -9,7 +9,6 @@ import { useRef, } from 'react' import { useTranslation } from 'react-i18next' -import { useThrottleEffect } from 'ahooks' import { debounce } from 'lodash-es' import type { ChatConfig, @@ -92,10 +91,19 @@ const Chat: FC = ({ chatFooterInnerRef.current.style.width = `${chatContainerInnerRef.current.clientWidth}px` }, []) - useThrottleEffect(() => { + useEffect(() => { handleScrolltoBottom() handleWindowResize() - }, [chatList], { wait: 500 }) + }, [handleScrolltoBottom, handleWindowResize]) + + useEffect(() => { + if (chatContainerRef.current) { + requestAnimationFrame(() => { + handleScrolltoBottom() + handleWindowResize() + }) + } + }) useEffect(() => { window.addEventListener('resize', debounce(handleWindowResize))