From ed58cc96d9c338955d6534ccdbf24af2e00f6929 Mon Sep 17 00:00:00 2001 From: Lee sang Yeop Date: Thu, 26 Oct 2023 19:01:59 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=EC=B1=84=ED=8C=85=20get=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=EC=8B=9C=20=EC=97=AD=EC=88=9C=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20=EC=B1=84=ED=8C=85=20=EC=88=9C=EC=84=9C?= =?UTF-8?q?=EB=A5=BC=20reverse=20=EB=A1=9C=20=EB=B0=98=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RoundCheckIn/CallAdminChat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/RoundCheckIn/CallAdminChat.tsx b/src/components/RoundCheckIn/CallAdminChat.tsx index 19b85c6..ce0402c 100644 --- a/src/components/RoundCheckIn/CallAdminChat.tsx +++ b/src/components/RoundCheckIn/CallAdminChat.tsx @@ -111,7 +111,7 @@ const CallAdminChat = ({ useEffect(() => { if (!matchMessages || matchMessages.length === 0) return; - setChats(matchMessages); + setChats(matchMessages.reverse()); }, [matchMessages]); return ( From 3849ffc52bc2d3fbb50a2ad06b04ff814e629213 Mon Sep 17 00:00:00 2001 From: Lee sang Yeop Date: Thu, 26 Oct 2023 19:12:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat:=20=EC=B1=84=ED=8C=85=EC=9D=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EB=90=98=EB=A9=B4=20=EC=83=88=EB=A1=9C?= =?UTF-8?q?=EC=9A=B4=20=EC=B1=84=ED=8C=85=EC=9D=B4=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=B4=EC=9D=B4=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RoundCheckIn/CallAdminChat.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/RoundCheckIn/CallAdminChat.tsx b/src/components/RoundCheckIn/CallAdminChat.tsx index ce0402c..c1951cd 100644 --- a/src/components/RoundCheckIn/CallAdminChat.tsx +++ b/src/components/RoundCheckIn/CallAdminChat.tsx @@ -3,7 +3,7 @@ import { css } from '@emotion/react'; import styled from '@emotion/styled'; import Image from 'next/image'; import { Client } from '@stomp/stompjs'; -import React, { useEffect, useState, ChangeEvent } from 'react'; +import React, { useEffect, useState, ChangeEvent, useRef } from 'react'; import { useRouter } from 'next/router'; import { BASE_PROFILE_IMG } from '@config/index'; @@ -26,6 +26,11 @@ const CallAdminChat = ({ const [inputMessage, setInputMessage] = useState(''); const router = useRouter(); const { channelLink } = router.query; + const chatEndRef = useRef(null); + + const scrollToBottom = () => { + chatEndRef.current?.scrollIntoView({ behavior: 'smooth' }); + }; const handleInputMessage = (e: ChangeEvent) => { setInputMessage(e.target.value); @@ -114,6 +119,10 @@ const CallAdminChat = ({ setChats(matchMessages.reverse()); }, [matchMessages]); + useEffect(() => { + scrollToBottom(); + }, [chats]); + return (
@@ -148,6 +157,7 @@ const CallAdminChat = ({ ))} +