[FEAT] 실시간 채팅 UI 구현 및 품질 개선#11
Merged
ydking0911 merged 10 commits intomainfrom Apr 2, 2026
Hidden character warning
The head ref may contain hidden characters: "feat/#10/\uc2e4\uc2dc\uac04-\ucc44\ud305-ui-\uad6c\ud604"
Merged
Conversation
- onAuthChange에서 로그인 이벤트 수신 시 getChatRooms() 호출 추가 - SSE 연결과 동시에 미확인 채팅 뱃지가 바로 반영되도록 수정
- ChatMessage 타입에 senderNickname 필드 추가 - 상대방 메시지에 닉네임, 이니셜 아바타 표시 - 시간/unreadCount 위치를 말풍선 옆으로 정렬, 폰트 크기 조정
Closed
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
KoungQ
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
백엔드 MySQL 기반 채팅 시스템 전환에 맞춰 채팅 UI 전체를 재구현. STOMP WebSocket 기반 실시간 메시지 송수신, 그룹/1:1 채팅 분기, 채팅방 정보 패널(멤버 목록), SSE 알림 연동까지 구현.
구현 기능
1. 채팅 상태 관리 — Zustand
chatStore채팅방 목록, 메시지 페이지네이션 상태, 읽음 카운트를 Zustand 스토어로 중앙 관리합니다.
chatRooms와messages를 분리 저장하고, 컴포넌트 간 상태 공유와 SSE 알림으로 인한 카운트 갱신 모두 스토어를 통해 처리신규 파일:
src/store/chatStore.ts,src/types/chat.ts2. 채팅방 목록 페이지 —
ChatPage기존 placeholder 화면에서 실제 채팅방 목록 렌더링으로 교체했습니다.
GET /api/chat/rooms로 목록을 불러와 최근 메시지 시각 기준으로 정렬 표시합니다. 로딩/에러/빈 상태를 각각 분기 처리수정 파일:
src/pages/ChatPage.tsx,src/components/chat/ChatRoomItem.tsx(신규)3. 채팅방 화면 —
ChatRoomPage(신규)파일:
src/pages/ChatRoomPage.tsxSTOMP WebSocket으로 실시간 메시지를 송수신 함. 그룹 채팅(
GROUP)과 1:1 채팅(DIRECT)을chatRoomType으로 분기해 제목 및 정보 패널을 다르게 표시@stomp/stompjs+SockJS,/topic/chat-room/{id}구독/app/chat-room/{id}/sendSTOMP publishPOST /api/chat/rooms/{id}/read+ unreadCount 0 리셋DELETE /api/chat/rooms/{id}/leave+ 2단 확인 UI그룹 채팅 멤버 목록 자동 갱신
정보 패널을 열 때
GET /api/chat/rooms/{id}/members를 호출해 최신 멤버 목록을 표시합니다. STOMP로 SYSTEM 메시지(입장·퇴장·강퇴)를 수신하면 멤버 목록을 자동 재조회해 UI를 동기화 함.STOMP 구독 콜백 내에서
showInfoPanel상태에 접근할 때 stale closure 문제가 발생할 수 있어,showInfoPanelRef를 별도로 유지해 항상 최신값을 참조하게 구현함.멤버 목록은 HOST가 항상 상단에 오도록
isHost필드 기준으로 정렬하고, 방장에게는 왕관(Crown) 아이콘을, 자신에게는 "(나)" 표시를 추가4. 메시지 말풍선 —
MessageBubble닉네임·아바타 추가파일:
src/components/chat/MessageBubble.tsx백엔드
ChatMessage에senderNickname필드가 추가됨에 따라, 상대방 말풍선에 발신자 닉네임과 이니셜 아바타를 표시5. 1:1 채팅 연결 —
MyRoomPage지원자 채팅 버튼파일:
src/pages/MyRoomPage.tsx지원자 목록에서 "채팅" 버튼 클릭 시, 기존 하드코딩 경로 대신
POST /api/rooms/{roomNo}/direct-chat/{applicantUserNo}를 호출해 DIRECT 채팅방 번호를 받아/chats/{chatRoomNo}로 이동. 로딩 중 버튼 비활성화 처리를 포함6. SSE 알림과 채팅 뱃지 연동 —
App.tsx파일:
src/App.tsxSSE로
NEW_MESSAGE_RECEIVED이벤트 수신 시,GET /api/chat/rooms를 다시 호출해chatStore를 서버 최신 상태로 갱신. 이를 통해 하단 탭의 읽지 않은 채팅 뱃지가 SSE 수신 즉시 반영로그인 이벤트(
onAuthChange)에서도getChatRooms()를 호출해, 로그인 직후 뱃지가 즉시 표시되도록 함현재 보고 있는 채팅방의 메시지 알림은 토스트를 표시하지 않음. (
window.location.pathname검사)버그 수정
BUG-1: 룸메이트 추가/퇴출 후 인원 표기 오류 (
5/4명)displayMembers에 서버에서 받은room.currentMateCount를 사용해, 클라이언트 상태(roommates배열)가 변해도 표기가 갱신되지 않음room.currentMateCount→roommates.length— 로컬 상태와 동기화src/pages/MyRoomPage.tsx:1051BUG-2: SSE 재연결 시 EventSource 강제 close로 자동 재연결 비활성화
eventSource.onerror에서eventSource.close()를 직접 호출해, 브라우저 내장 자동 재연결(exponential backoff)이 취소됨close()호출 제거 — 브라우저가 재연결 타이밍을 관리하도록 위임src/services/notification.tsBUG-3: 방 지원 API 경로 불일치
/join-request→/request)을 FE가 반영하지 않아 지원 API 404 응답ApplyRoomModal.tsx,RoomSearchPage.tsx,MyRoomPage.tsx에서 경로 일괄 수정체크리스트
reconnectDelay: 5000자동 재연결NOT_CHAT_ROOM_MEMBER에러 처리 + 목록으로 이동HOST_CANNOT_LEAVE에러 메시지 안내var(--vh, 100dvh))-webkit-overflow-scrolling: touch)스크린샷