@@ -19,6 +19,7 @@ import { MessagesContainer } from './styles';
1919
2020const MatchingRoom : React . FC = ( ) => {
2121 const [ allMatchings , setAllMatchings ] = useState < MatchingData [ ] > ( [ ] ) ;
22+ const [ hasNewMatching , setHasNewMatching ] = useState ( true ) ;
2223
2324 const [ isLoading , setIsLoading ] = useState ( true ) ;
2425 const [ isScroll , setIsScroll ] = useState ( false ) ;
@@ -55,15 +56,17 @@ const MatchingRoom: React.FC = () => {
5556 useEffect ( ( ) => {
5657 // 전체 매칭 불러오기 socket api
5758 const getAllMatchings = ( { matching } : { matching : MatchingData [ ] } ) => {
58- console . log ( allMatchings ) ;
5959 setAllMatchings ( matching ) ;
6060 setIsScroll ( true ) ;
6161 setIsLoading ( false ) ;
6262 } ;
6363
6464 const getNewMatching = ( data : MatchingData ) => {
65- if ( JSON . stringify ( data ) === '{}' ) return ;
66- setAllMatchings ( [ ...allMatchings , data ] ) ;
65+ if ( JSON . stringify ( data ) === '{}' ) {
66+ setHasNewMatching ( false ) ;
67+ } else {
68+ setAllMatchings ( [ ...allMatchings , data ] ) ;
69+ }
6770 } ;
6871
6972 if ( socket ) {
@@ -95,7 +98,6 @@ const MatchingRoom: React.FC = () => {
9598 < NoMatchingMessage />
9699 ) : (
97100 allMatchings . map ( ( matching : MatchingData ) => {
98- // TODO: 매칭 상태에 따라 응답 버튼 렌더링
99101 return (
100102 < div key = { matching . id } >
101103 < MatchingMessage { ...matching } />
@@ -104,6 +106,7 @@ const MatchingRoom: React.FC = () => {
104106 ) ;
105107 } )
106108 ) }
109+ { ! hasNewMatching && < NoMatchingMessage /> }
107110 < div ref = { chatWindowRef } />
108111 </ MessagesContainer >
109112 < ChatBox disabled = { true } />
0 commit comments