diff --git a/src/page/Meeting/ChatBigWindow/index.tsx b/src/page/Meeting/ChatBigWindow/index.tsx index cfe6bb2..e87418b 100644 --- a/src/page/Meeting/ChatBigWindow/index.tsx +++ b/src/page/Meeting/ChatBigWindow/index.tsx @@ -37,12 +37,6 @@ const ChatBigWindow: React.FC = () => { } window.electron.windowHandleMessageCallBack((_e: any, data: any) => { setChatLists(data.parmes.chatList) - setTimeout(() => { - const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; - if (chatBigWindowView) { - chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; - } - }, 100) }) channel.postMessage({ type: 'chatBigWindowSendChannelMsg', @@ -54,6 +48,12 @@ const ChatBigWindow: React.FC = () => { channel.close(); } }, []); + useEffect(() => { + const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; + if (chatBigWindowView) { + chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; + } + }, [chatLists]); return ( <> diff --git a/src/page/Meeting/ChatSmallWindow/index.tsx b/src/page/Meeting/ChatSmallWindow/index.tsx index 9df2e94..0a9da32 100644 --- a/src/page/Meeting/ChatSmallWindow/index.tsx +++ b/src/page/Meeting/ChatSmallWindow/index.tsx @@ -15,17 +15,17 @@ const ChatSmallWindow: React.FC = () => { }, 10000); return [data.parmes.chatListIten, ...newChatList] }) - setTimeout(() => { - const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement; - if (chatSmallWindowView) { - chatSmallWindowView.scrollTop = chatSmallWindowView.scrollHeight; - } - }, 100) }) return () => { channel.close(); } }, []); + useEffect(() => { + const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; + if (chatBigWindowView) { + chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; + } + }, [chatLists]); const removeItemByIndex = () => { setChatLists((res: any) => { return res.slice(0, -1)