[FIX] improve room management flows and persist room rule edits#13
Hidden character warning
[FIX] improve room management flows and persist room rule edits#13ydking0911 wants to merge 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
방 관리/채팅/검색 화면에서 “방 상태 동기화”와 “방 규칙 편집 저장 반영” 흐름을 개선하고, 방 삭제/나가기/강퇴 이후 스토어 및 화면 상태 정리를 추가하는 PR입니다.
Changes:
- 방 관리(MyRoomPage)에서 규칙 저장 반영, 방 삭제/나가기/룸메이트 내보내기 액션 및 UI 조건을 정리
- 채팅방(ChatRoomPage)에서 룸메이트 메타(confirmStatus/isMe) 반영, 강퇴/삭제 알림 수신 시 스토어 정리, stale closure 방지용 ref 동기화 추가
- 방 검색(RoomSearchPage)에서 location state 기반으로 삭제/나가기 후 목록/확장/메모/좋아요 상태를 정리하고, 게스트/로그인 UI 노출 조건을 정리
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/bun-test.d.ts | bun:test 타입 선언 추가로 유틸 테스트 타입체크 지원 |
| src/store/chatStore.ts | 채팅방/그룹채팅방 제거 유틸 추가(스토어 정리 기능) |
| src/services/roomApi.ts | 룸메이트 강퇴/방 삭제 API 클라이언트 추가 |
| src/services/chatApi.ts | roomNo로 내 그룹 채팅방 찾는 유틸 추가 |
| src/pages/roomSearchDeleteState.js | 방 삭제/나가기 이후 RoomSearchPage 상태 pruning 유틸 추가 |
| src/pages/roomSearchDeleteState.d.ts | pruning 유틸 타입 정의 추가 |
| src/pages/myRoomRuleUtils.ts | 룸 규칙 fetch 경로/단일 선택/시간값 보정 유틸 추가 |
| src/pages/myRoomRuleUtils.test.ts | myRoomRuleUtils에 대한 단위 테스트 추가 |
| src/pages/RoomSearchPage.tsx | location state 기반 상태 정리 + 게스트 UI 조건 + otherNotes 처리 보강 |
| src/pages/MyRoomPage.tsx | 룰 저장 반영/삭제/나가기/강퇴 기능 연결 및 호스트 UI 조건 정리 |
| src/pages/ChatRoomPage.tsx | 멤버 메타 병합, 강퇴 UI, 알림 구독 시 스토어 정리, stale closure 방지 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| if (!deletedRoomNo) return | ||
|
|
||
| const nextState = pruneDeletedRoomState( | ||
| { |
There was a problem hiding this comment.
This effect reads multiple state values (recruitingRooms/appliedRooms/joinedRooms/expandedRoomIds/roomRules/roomOtherNotes/likedRoomIds) but the dependency array only includes deletedRoomNo. With the repo’s eslint settings (react-hooks/exhaustive-deps + --max-warnings 0), this will raise a lint warning and fail CI. Instead of adding all those deps (which can cause repeated runs), consider applying the prune via functional setState updates per field, or consume and then clear the location.state (replace navigation) so the effect can safely depend on all required values without looping.
| const notification: NotificationMessage = JSON.parse(msg.body) | ||
|
|
There was a problem hiding this comment.
JSON.parse(msg.body) in the notification subscription is unguarded. If the server ever sends a non-JSON payload (or an unexpected schema), this will throw inside the STOMP callback and can break message handling / crash the page. Wrap the parse in a try/catch and ignore (or surface) invalid messages safely.
| const notification: NotificationMessage = JSON.parse(msg.body) | |
| let parsedNotification: unknown | |
| try { | |
| parsedNotification = JSON.parse(msg.body) | |
| } catch (error) { | |
| console.error('Invalid notification message payload:', error, msg.body) | |
| return | |
| } | |
| if ( | |
| !parsedNotification || | |
| typeof parsedNotification !== 'object' || | |
| typeof (parsedNotification as NotificationMessage).chatRoomNo !== 'string' || | |
| typeof (parsedNotification as NotificationMessage).type !== 'string' | |
| ) { | |
| console.error('Unexpected notification message payload:', parsedNotification) | |
| return | |
| } | |
| const notification = parsedNotification as NotificationMessage |
| if (notification.type === 'KICKED_FROM_ROOM') { | ||
| removeChatRoom(notification.chatRoomNo) | ||
| toast.error('방에서 강퇴되었습니다.') | ||
| navigate('/rooms/search') | ||
| return | ||
| } | ||
|
|
||
| if (notification.type === 'ROOM_DELETED') { | ||
| removeChatRoom(notification.chatRoomNo) | ||
| toast.error('방이 삭제되었습니다.') | ||
| navigate('/rooms/search') | ||
| } |
There was a problem hiding this comment.
This STOMP connection effect’s dependency array is only [chatRoomNo], but it now also closes over values like removeChatRoom, navigate, appendMessage, updateRoomOnNewMessage, and fetchMessages. With react-hooks/exhaustive-deps enabled (and --max-warnings 0), this will trigger a lint warning. Either add the missing dependencies (if they’re stable) or move the referenced callbacks into refs (similar to fetchMembersRef / markAsReadAndSyncRef) so the effect can remain keyed by chatRoomNo only.
요약
방 관리 흐름과 채팅/검색 화면의 방 상태 동기화를 개선했습니다.
특히 방 관리에서 규칙 편집 후 저장해도 이전 값으로 보이던 문제를 수정했고,
방 삭제/방 나가기/룸메이트 내보내기 이후 관련 화면 상태가 자연스럽게 반영되도록 정리했습니다.
변경 사항
1. 방 관리(MyRoomPage) 개선
2. 채팅방(ChatRoomPage) 상태 동기화
3. 방 검색(RoomSearchPage) 상태 동기화
4. 공통 유틸 및 API 추가
buildRoomRuleFetchPathselectSingleOptionnormalizeRoomRuleTimeValueroomApi추가roomSearchDeleteState유틸 추가기대 효과
참고
room rule update no-op수정이 함께 반영되어야 합니다.