From 933b3faa1bc103460c28f6a29fd5ab0ba103077b Mon Sep 17 00:00:00 2001 From: nueijeel Date: Sat, 21 Feb 2026 15:50:22 +0900 Subject: [PATCH 01/14] =?UTF-8?q?fix:=20get=20bookmarks=20list=20api=20end?= =?UTF-8?q?=20point=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/catchmate/data/datasource/remote/BoardService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/BoardService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/BoardService.kt index 43a6974b..5b024f35 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/BoardService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/BoardService.kt @@ -64,7 +64,7 @@ interface BoardService { @Path("boardId") boardId: Long, ): Response - @GET("api/bookmarks/me") + @GET("api/bookmarks") suspend fun getLikedBoard( @Query("page") page: Int, @Query("size") size: Int = 10, From 8967145689569d94b1ec141be757b2fb76bb63be Mon Sep 17 00:00:00 2001 From: nueijeel Date: Sat, 21 Feb 2026 15:52:51 +0900 Subject: [PATCH 02/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=ED=91=9C=EC=8B=9C=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95,=20=EA=B4=80=EB=A0=A8=20api=20response=20?= =?UTF-8?q?dto=20=EB=B0=8F=20model=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/chatting/ChatRoomInfoDTO.kt | 1 + .../catchmate/data/mapper/ChattingMapper.kt | 1 + .../domain/model/chatting/ChatRoomInfo.kt | 1 + .../view/chatting/ChattingHomeFragment.kt | 6 ----- .../view/chatting/ChattingRoomListAdapter.kt | 23 ++++++++----------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt index eb278368..abcec69d 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt @@ -6,5 +6,6 @@ data class ChatRoomInfoDTO( val chatRoomId: Long, val board: BoardDTO, val lastMessage: LastMessageInfoDto?, + val unreadCount: Long, val createdAt: String, ) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index 220023f5..d60811b2 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -40,6 +40,7 @@ object ChattingMapper { chatRoomId = dto.chatRoomId, board = toBoard(dto.board), lastMessage = toLastMessageInfo(dto.lastMessage), + unreadCount = dto.unreadCount, createdAt = dto.createdAt, ) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt index a21c26eb..55d15bd1 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt @@ -6,5 +6,6 @@ data class ChatRoomInfo( val chatRoomId: Long, val board: Board, val lastMessage: LastMessageInfo?, + val unreadCount: Long, val createdAt: String, ) diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt index 9e79a24d..0ed6befb 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt @@ -20,7 +20,6 @@ import com.catchmate.presentation.interaction.OnListItemAllRemovedListener import com.catchmate.presentation.util.ReissueUtil.NAVIGATE_CODE_REISSUE import com.catchmate.presentation.view.base.BaseFragment import com.catchmate.presentation.viewmodel.ChattingHomeViewModel -import com.catchmate.presentation.viewmodel.LocalDataViewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.AndroidEntryPoint @@ -32,7 +31,6 @@ class ChattingHomeFragment : OnItemSwipeListener, OnListItemAllRemovedListener { private val chattingHomeViewModel: ChattingHomeViewModel by viewModels() - private val localDataViewModel: LocalDataViewModel by viewModels() private var currentPage: Int = 0 private var hasNext = true private var isLoading = false @@ -51,7 +49,6 @@ class ChattingHomeFragment : val deletedChatRoomId = bundle.getLong("chatRoomId") deleteChatRoom(deletedChatRoomId) } - localDataViewModel.getAccessToken() initHeader() initRecyclerView() initViewModel() @@ -93,9 +90,6 @@ class ChattingHomeFragment : } private fun initViewModel() { - localDataViewModel.accessToken.observe(viewLifecycleOwner) { token -> -// chattingHomeViewModel.connectToWebSocket(token) - } chattingHomeViewModel.getChattingRoomListResponse.observe(viewLifecycleOwner) { response -> isLoading = false if (!response.hasNext && response.totalElements == 0) { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt index 2c214b7a..ec92c5c6 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt @@ -95,28 +95,23 @@ class ChattingRoomListAdapter( ) tvChattingItemTitle.text = chatRoomInfo.board.title + tvChattingItemTime.text = formatLastChatTime(chatRoomInfo.createdAt) if (chatRoomInfo.lastMessage == null) { tvChattingItemNew.visibility = View.VISIBLE tvChattingItemPeopleCount.visibility = View.GONE + tvChattingItemLastChat.text = root.context.getString(R.string.chatting_start_message) + tvChattingItemUnreadMessageCount.visibility = View.GONE } else { tvChattingItemNew.visibility = View.GONE tvChattingItemPeopleCount.visibility = View.VISIBLE tvChattingItemPeopleCount.text = chatRoomInfo.board.currentPerson.toString() - } - - if (chatRoomInfo.lastMessage == null) { - tvChattingItemLastChat.text = root.context.getString(R.string.chatting_start_message) - tvChattingItemTime.text = "방금" - tvChattingItemUnreadMessageCount.visibility = View.GONE - } else { tvChattingItemLastChat.text = chatRoomInfo.lastMessage?.content - tvChattingItemTime.text = formatLastChatTime(chatRoomInfo.lastMessage?.createdAt!!) -// if (chatRoomInfo.unreadMessageCount == 0) { -// tvChattingItemUnreadMessageCount.visibility = View.GONE -// } else { -// tvChattingItemUnreadMessageCount.visibility = View.VISIBLE -// tvChattingItemUnreadMessageCount.text = chatRoomInfo.unreadMessageCount.toString() -// } + if (chatRoomInfo.unreadCount == 0L) { + tvChattingItemUnreadMessageCount.visibility = View.GONE + } else { + tvChattingItemUnreadMessageCount.visibility = View.VISIBLE + tvChattingItemUnreadMessageCount.text = chatRoomInfo.unreadCount.toString() + } } } } From 634d4e5b3f7e4e9bb4813e33f3584c74194f4cd8 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Sat, 21 Feb 2026 22:43:11 +0900 Subject: [PATCH 03/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20api=20=EB=B0=8F=20=EC=86=8C=EC=BC=93=20?= =?UTF-8?q?=ED=86=B5=EC=8B=A0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 채팅 참여자 목록 api, 채팅 내역 api 수정사항 반영 - 소켓 연결 및 채팅방 메시지 구독, 읽음 여부 전송, 메시지 전송 연결 --- .../data/datasource/remote/ChattingService.kt | 18 +- .../data/dto/chatting/ChatMessageIdDTO.kt | 6 - .../data/dto/chatting/ChatMessageInfoDTO.kt | 10 - .../GetChattingCrewListResponseDTO.kt | 8 +- .../chatting/GetChattingHistoryResponseDTO.kt | 8 - .../GetChattingMessagesResponseDTO.kt | 12 + .../catchmate/data/mapper/ChattingMapper.kt | 43 ++-- .../data/repository/ChattingRepositoryImpl.kt | 26 +- .../domain/model/chatting/ChatMessageId.kt | 6 - .../domain/model/chatting/ChatMessageInfo.kt | 10 - .../chatting/GetChattingCrewListResponse.kt | 7 +- .../chatting/GetChattingHistoryResponse.kt | 8 - .../chatting/GetChattingMessagesResponse.kt | 12 + .../domain/model/enumclass/ChatMessageType.kt | 1 + .../domain/repository/ChattingRepository.kt | 12 +- .../chatting/GetChattingCrewListUseCase.kt | 2 +- ...eCase.kt => GetChattingMessagesUseCase.kt} | 10 +- .../catchmate/presentation/util/DateUtils.kt | 35 +-- .../view/chatting/ChatListAdapter.kt | 44 ++-- .../view/chatting/ChattingCrewListAdapter.kt | 16 +- .../view/chatting/ChattingRoomFragment.kt | 86 +++---- .../view/chatting/ChattingSettingFragment.kt | 11 +- .../viewmodel/ChattingRoomViewModel.kt | 238 +++++++++--------- 23 files changed, 305 insertions(+), 324 deletions(-) delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageIdDTO.kt delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageInfoDTO.kt delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingHistoryResponseDTO.kt create mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingMessagesResponseDTO.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageId.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageInfo.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingHistoryResponse.kt create mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingMessagesResponse.kt rename CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/{GetChattingHistoryUseCase.kt => GetChattingMessagesUseCase.kt} (51%) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt index 83f143a6..38dd16bf 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt @@ -4,7 +4,7 @@ import com.catchmate.data.dto.chatting.ChatRoomInfoDTO import com.catchmate.data.dto.chatting.DeleteChattingCrewKickOutResponseDTO import com.catchmate.data.dto.chatting.DeleteChattingRoomResponseDTO import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO -import com.catchmate.data.dto.chatting.GetChattingHistoryResponseDTO +import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO import com.catchmate.data.dto.chatting.PatchChattingRoomImageResponseDTO import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO @@ -26,10 +26,10 @@ interface ChattingService { @Query("size") size: Int, ): Response - @GET("chat-rooms/{chatRoomId}/user-list") + @GET("api/chat/rooms/{chatRoomId}/members") suspend fun getChattingCrewList( @Path("chatRoomId") chatRoomId: Long, - ): Response + ): Response?> @GET("chat-rooms/{chatRoomId}") suspend fun getChattingRoomInfo( @@ -60,10 +60,10 @@ interface ChattingService { @Path("userId") userId: Long, ): Response - @GET("chats/{chatRoomId}") - suspend fun getChattingHistory( - @Path("chatRoomId") chatRoomId: Long, - @Query("lastMessageId") lastMessageId: String?, - @Query("size") size: Int?, // default = 20 - ): Response + @GET("api/chat/rooms/{roomId}/messages") + suspend fun getChattingMessages( + @Path("roomId") roomId: Long, + @Query("lastMessageId") lastMessageId: Long?, + @Query("size") size: Int, // default = 20 + ): Response?> } diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageIdDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageIdDTO.kt deleted file mode 100644 index a46d5a8a..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageIdDTO.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class ChatMessageIdDTO( - val timestamp: Long? = null, - val date: String, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageInfoDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageInfoDTO.kt deleted file mode 100644 index 2340f9de..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatMessageInfoDTO.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class ChatMessageInfoDTO( - val id: ChatMessageIdDTO, - val chatMessageId: String, - val roomId: Long? = null, - val content: String, - val senderId: Long, - val messageType: String, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingCrewListResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingCrewListResponseDTO.kt index 995d1c85..64e67f2e 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingCrewListResponseDTO.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingCrewListResponseDTO.kt @@ -1,7 +1,9 @@ package com.catchmate.data.dto.chatting -import com.catchmate.data.dto.user.GetUserProfileResponseDTO - data class GetChattingCrewListResponseDTO( - val userInfoList: List, + val memberId: Long, + val userId: Long, + val nickName: String, + val profileImageUrl: String, + val joinedAt: String, ) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingHistoryResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingHistoryResponseDTO.kt deleted file mode 100644 index ab8c3943..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingHistoryResponseDTO.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class GetChattingHistoryResponseDTO( - val chatMessageInfoList: List, - val isFirst: Boolean, - val isLast: Boolean, - val lastMessageId: String?, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingMessagesResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingMessagesResponseDTO.kt new file mode 100644 index 00000000..70b32af6 --- /dev/null +++ b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/GetChattingMessagesResponseDTO.kt @@ -0,0 +1,12 @@ +package com.catchmate.data.dto.chatting + +data class GetChattingMessagesResponseDTO( + val messageId: Long, + val chatRoomId: Long, + val senderId: Long, + val senderNickName: String, + val senderProfileImageUrl: String, + val content: String, + val messageType: String, + val createdAt: String, +) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index d60811b2..c1f87b91 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -1,25 +1,20 @@ package com.catchmate.data.mapper -import com.catchmate.data.dto.chatting.ChatMessageIdDTO -import com.catchmate.data.dto.chatting.ChatMessageInfoDTO import com.catchmate.data.dto.chatting.ChatRoomInfoDTO import com.catchmate.data.dto.chatting.DeleteChattingCrewKickOutResponseDTO import com.catchmate.data.dto.chatting.DeleteChattingRoomResponseDTO import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO -import com.catchmate.data.dto.chatting.GetChattingHistoryResponseDTO +import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO import com.catchmate.data.dto.chatting.LastMessageInfoDto import com.catchmate.data.dto.chatting.PatchChattingRoomImageResponseDTO import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO import com.catchmate.data.mapper.BoardMapper.toBoard -import com.catchmate.data.mapper.UserMapper.toGetUserProfileResponse -import com.catchmate.domain.model.chatting.ChatMessageId -import com.catchmate.domain.model.chatting.ChatMessageInfo import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse -import com.catchmate.domain.model.chatting.GetChattingHistoryResponse +import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse import com.catchmate.domain.model.chatting.LastMessageInfo import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse @@ -58,33 +53,25 @@ object ChattingMapper { ) } - fun toGetChattingHistoryResponse(dto: GetChattingHistoryResponseDTO): GetChattingHistoryResponse = - GetChattingHistoryResponse( - chatMessageInfoList = dto.chatMessageInfoList.map { toChatMessageInfo(it) }, - isFirst = dto.isFirst, - isLast = dto.isLast, - lastMessageId = dto.lastMessageId, - ) - - private fun toChatMessageInfo(dto: ChatMessageInfoDTO): ChatMessageInfo = - ChatMessageInfo( - id = toChatMessageId(dto.id), - chatMessageId = dto.chatMessageId, - roomId = dto.roomId, - content = dto.content, + fun toGetChattingHistoryResponse(dto: GetChattingMessagesResponseDTO): GetChattingMessagesResponse = + GetChattingMessagesResponse( + messageId = dto.messageId, + chatRoomId = dto.chatRoomId, senderId = dto.senderId, + senderNickName = dto.senderNickName, + senderProfileImageUrl = dto.senderProfileImageUrl, + content = dto.content, messageType = dto.messageType, - ) - - private fun toChatMessageId(dto: ChatMessageIdDTO): ChatMessageId = - ChatMessageId( - timestamp = dto.timestamp, - date = dto.date, + createdAt = dto.createdAt, ) fun toGetChattingCrewListResponse(dto: GetChattingCrewListResponseDTO): GetChattingCrewListResponse = GetChattingCrewListResponse( - userInfoList = dto.userInfoList.map { toGetUserProfileResponse(it) }, + memberId = dto.memberId, + userId = dto.userId, + nickName = dto.nickName, + profileImageUrl = dto.profileImageUrl, + joinedAt = dto.joinedAt, ) fun toDeleteChattingRoomResponse(dto: DeleteChattingRoomResponseDTO): DeleteChattingRoomResponse = diff --git a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt index ceb08bda..021a359a 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt @@ -8,7 +8,7 @@ import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse -import com.catchmate.domain.model.chatting.GetChattingHistoryResponse +import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse @@ -34,11 +34,15 @@ class ChattingRepositoryImpl transform = { ChattingMapper.toGetChattingRoomListResponse(it!!) }, ) - override suspend fun getChattingCrewList(chatRoomId: Long): Result = + override suspend fun getChattingCrewList(chatRoomId: Long): Result> = apiCall( tag = this.tag, apiFunction = { chattingApi.getChattingCrewList(chatRoomId) }, - transform = { ChattingMapper.toGetChattingCrewListResponse(it!!) }, + transform = { list -> + list?.map { crew -> + ChattingMapper.toGetChattingCrewListResponse(crew) + } ?: emptyList() + }, ) override suspend fun getChattingRoomInfo(chatRoomId: Long): Result = @@ -85,14 +89,18 @@ class ChattingRepositoryImpl transform = { ChattingMapper.toDeleteChattingCrewKickOutResponse(it!!) }, ) - override suspend fun getChattingHistory( + override suspend fun getChattingMessages( chatRoomId: Long, - lastMessageId: String?, - size: Int?, - ): Result = + lastMessageId: Long?, + size: Int, + ): Result> = apiCall( tag = this.tag, - apiFunction = { chattingApi.getChattingHistory(chatRoomId, lastMessageId, size) }, - transform = { ChattingMapper.toGetChattingHistoryResponse(it!!) }, + apiFunction = { chattingApi.getChattingMessages(chatRoomId, lastMessageId, size) }, + transform = { list -> + list?.map { message -> + ChattingMapper.toGetChattingHistoryResponse(message) + } ?: emptyList() + }, ) } diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageId.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageId.kt deleted file mode 100644 index cc5c3d2e..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageId.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class ChatMessageId( - val timestamp: Long? = null, - val date: String, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageInfo.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageInfo.kt deleted file mode 100644 index 99eba8cb..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatMessageInfo.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class ChatMessageInfo( - val id: ChatMessageId? = null, - val chatMessageId: String, - val roomId: Long? = null, - val content: String, - val senderId: Long, - val messageType: String, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingCrewListResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingCrewListResponse.kt index 5ec28e7d..8b6fd78d 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingCrewListResponse.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingCrewListResponse.kt @@ -1,10 +1,13 @@ package com.catchmate.domain.model.chatting import android.os.Parcelable -import com.catchmate.domain.model.user.GetUserProfileResponse import kotlinx.parcelize.Parcelize @Parcelize data class GetChattingCrewListResponse( - val userInfoList: List, + val memberId: Long, + val userId: Long, + val nickName: String, + val profileImageUrl: String, + val joinedAt: String, ) : Parcelable diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingHistoryResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingHistoryResponse.kt deleted file mode 100644 index 7e9489ee..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingHistoryResponse.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class GetChattingHistoryResponse( - val chatMessageInfoList: List, - val isFirst: Boolean, - val isLast: Boolean, - val lastMessageId: String?, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingMessagesResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingMessagesResponse.kt new file mode 100644 index 00000000..e065d421 --- /dev/null +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/GetChattingMessagesResponse.kt @@ -0,0 +1,12 @@ +package com.catchmate.domain.model.chatting + +data class GetChattingMessagesResponse( + val messageId: Long, + val chatRoomId: Long, + val senderId: Long, + val senderNickName: String, + val senderProfileImageUrl: String, + val content: String, + val messageType: String, + val createdAt: String, +) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt index 1b9a028c..30f30edb 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt @@ -5,4 +5,5 @@ enum class ChatMessageType { DATE, ENTER, LEAVE, + TEXT, } diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt index 08ffd9b6..1a88c6ac 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt @@ -4,7 +4,7 @@ import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse -import com.catchmate.domain.model.chatting.GetChattingHistoryResponse +import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse @@ -16,7 +16,7 @@ interface ChattingRepository { size: Int, ): Result - suspend fun getChattingCrewList(chatRoomId: Long): Result + suspend fun getChattingCrewList(chatRoomId: Long): Result> suspend fun getChattingRoomInfo(chatRoomId: Long): Result @@ -37,9 +37,9 @@ interface ChattingRepository { userId: Long, ): Result - suspend fun getChattingHistory( + suspend fun getChattingMessages( chatRoomId: Long, - lastMessageId: String?, - size: Int?, - ): Result + lastMessageId: Long?, + size: Int, + ): Result> } diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingCrewListUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingCrewListUseCase.kt index 3aaa09dd..1a865968 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingCrewListUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingCrewListUseCase.kt @@ -9,6 +9,6 @@ class GetChattingCrewListUseCase constructor( private val chattingRepository: ChattingRepository, ) { - suspend operator fun invoke(chatRoomId: Long): Result = + suspend operator fun invoke(chatRoomId: Long): Result> = chattingRepository.getChattingCrewList(chatRoomId) } diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingHistoryUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingMessagesUseCase.kt similarity index 51% rename from CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingHistoryUseCase.kt rename to CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingMessagesUseCase.kt index cbe1a09f..b95f677b 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingHistoryUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingMessagesUseCase.kt @@ -1,17 +1,17 @@ package com.catchmate.domain.usecase.chatting -import com.catchmate.domain.model.chatting.GetChattingHistoryResponse +import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.repository.ChattingRepository import javax.inject.Inject -class GetChattingHistoryUseCase +class GetChattingMessagesUseCase @Inject constructor( private val chattingRepository: ChattingRepository, ) { suspend operator fun invoke( chatRoomId: Long, - lastMessageId: String?, - size: Int?, - ): Result = chattingRepository.getChattingHistory(chatRoomId, lastMessageId, size) + lastMessageId: Long?, + size: Int, + ): Result> = chattingRepository.getChattingMessages(chatRoomId, lastMessageId, size) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt index 5c11060b..b442a687 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt @@ -5,7 +5,6 @@ import java.time.Duration import java.time.Instant import java.time.LocalDateTime import java.time.ZoneId -import java.time.ZonedDateTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatterBuilder import java.time.temporal.ChronoField @@ -152,20 +151,26 @@ object DateUtils { // 채팅 전송 시간 포맷하는 함수 fun formatChatSendTime(dateTime: String): String { - val formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME - val parsedTime = - ZonedDateTime - .parse(dateTime, formatter) - .withZoneSameInstant(ZoneId.of("Asia/Seoul")) // 시스템 시간대로 변환 - - val outputFormatter = DateTimeFormatter.ofPattern("a h:mm") // "오전 4:55" 형식 - return parsedTime.format(outputFormatter) - } - - // 채팅 수신 시 날짜값 포맷하는 함수 - fun getCurrentTimeFormatted(): String { - val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX") - return ZonedDateTime.now().format(formatter) + val tFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS") + val spaceFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + val outputFormatter = DateTimeFormatter.ofPattern("a h:mm") + return try { + // 시간대 정보가 없는 문자열을 LocalDateTime으로 파싱 + val localDateTime = + if (dateTime.contains("T")) { + LocalDateTime.parse(dateTime) + } else { + LocalDateTime.parse(dateTime, spaceFormatter) + } + + localDateTime + .atZone(ZoneId.of("UTC")) + .withZoneSameInstant(ZoneId.of("Asia/Seoul")) + .format(outputFormatter) + } catch (e: Exception) { + e.printStackTrace() + "" // 에러 발생 시 빈 문자열 또는 기본값 반환 + } } fun checkIsFinishedGame(dateTime: String): Boolean { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt index 62080b5d..08016416 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt @@ -7,9 +7,9 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide -import com.catchmate.domain.model.chatting.ChatMessageInfo +import com.catchmate.domain.model.chatting.GetChattingCrewListResponse +import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.enumclass.ChatMessageType -import com.catchmate.domain.model.user.GetUserProfileResponse import com.catchmate.presentation.R import com.catchmate.presentation.databinding.ItemReceivedChatBinding import com.catchmate.presentation.databinding.ItemSendChatBinding @@ -19,34 +19,34 @@ import com.catchmate.presentation.util.DateUtils.formatChatSendTime class ChatListAdapter( private val userId: Long, - private val chattingCrewList: List, -) : ListAdapter(diffUtil) { + private val chattingCrewList: List, +) : ListAdapter(diffUtil) { inner class SendChatViewHolder( private val binding: ItemSendChatBinding, ) : RecyclerView.ViewHolder(binding.root) { - fun bind(chatMessageInfo: ChatMessageInfo) { - binding.tvSendChatMessage.text = chatMessageInfo.content - binding.tvSendChatTime.text = formatChatSendTime(chatMessageInfo.id?.date!!) + fun bind(chat: GetChattingMessagesResponse) { + binding.tvSendChatMessage.text = chat.content + binding.tvSendChatTime.text = formatChatSendTime(chat.createdAt) } } inner class ReceivedChatViewHolder( private val binding: ItemReceivedChatBinding, ) : RecyclerView.ViewHolder(binding.root) { - fun bind(chatMessageInfo: ChatMessageInfo) { + fun bind(chat: GetChattingMessagesResponse) { // 현재 메시지가 리스트의 마지막인지 확인 val isLastMessage = absoluteAdapterPosition == currentList.lastIndex // 현재 메시지와 다음 메시지의 senderId가 같은지 비교 val isSameSenderAsNext = absoluteAdapterPosition < currentList.lastIndex && - currentList[absoluteAdapterPosition + 1].senderId == chatMessageInfo.senderId + currentList[absoluteAdapterPosition + 1].senderId == chat.senderId if (isLastMessage || !isSameSenderAsNext) { // 마지막 메시지(서버에서 주는 데이터를 역순으로 스크롤하게 출력했기 때문에 마지막 메시지인지 판단)이거나 다음 메시지와 보낸 사람이 다르면 프로필과 닉네임 표시 binding.ivReceivedChatProfile.visibility = View.VISIBLE binding.tvReceivedChatNickname.visibility = View.VISIBLE val currentUserInfo = - chattingCrewList.firstOrNull { it.userId == chatMessageInfo.senderId } + chattingCrewList.firstOrNull { it.userId == chat.senderId } binding.tvReceivedChatNickname.text = currentUserInfo?.nickName ?: "알수없음" Glide .with(binding.root) @@ -58,16 +58,16 @@ class ChatListAdapter( binding.ivReceivedChatProfile.visibility = View.GONE binding.tvReceivedChatNickname.visibility = View.GONE } - binding.tvReceivedChatMessage.text = chatMessageInfo.content - binding.tvReceivedChatTime.text = formatChatSendTime(chatMessageInfo.id?.date!!) + binding.tvReceivedChatMessage.text = chat.content + binding.tvReceivedChatTime.text = formatChatSendTime(chat.createdAt) } } inner class ChattingDateViewHolder( private val binding: ViewChattingDateBinding, ) : RecyclerView.ViewHolder(binding.root) { - fun bind(chatMessageInfo: ChatMessageInfo) { - binding.tvChattingDate.text = chatMessageInfo.content + fun bind(chat: GetChattingMessagesResponse) { + binding.tvChattingDate.text = chat.content } } @@ -75,11 +75,11 @@ class ChatListAdapter( private val binding: ViewChattingParticipantAlertBinding, ) : RecyclerView.ViewHolder(binding.root) { fun bind( - chatMessageInfo: ChatMessageInfo, + chat: GetChattingMessagesResponse, viewType: Int, ) { val nickname = - chattingCrewList.firstOrNull { it.userId == chatMessageInfo.senderId }?.nickName ?: "알수없음" + chattingCrewList.firstOrNull { it.userId == chat.senderId }?.nickName ?: "알수없음" val message = if (viewType == ENTER) { "$nickname 님이 채팅에 참여했어요" @@ -150,7 +150,7 @@ class ChatListAdapter( override fun getItemViewType(position: Int): Int = when (currentList[position].messageType) { - ChatMessageType.TALK.name -> { + ChatMessageType.TEXT.name -> { if (currentList[position].senderId == userId) { MY_CHAT } else { @@ -173,15 +173,15 @@ class ChatListAdapter( companion object { val diffUtil = - object : DiffUtil.ItemCallback() { + object : DiffUtil.ItemCallback() { override fun areItemsTheSame( - oldItem: ChatMessageInfo, - newItem: ChatMessageInfo, + oldItem: GetChattingMessagesResponse, + newItem: GetChattingMessagesResponse, ): Boolean = oldItem == newItem override fun areContentsTheSame( - oldItem: ChatMessageInfo, - newItem: ChatMessageInfo, + oldItem: GetChattingMessagesResponse, + newItem: GetChattingMessagesResponse, ): Boolean = oldItem == newItem } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingCrewListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingCrewListAdapter.kt index 590828d6..12ab712e 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingCrewListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingCrewListAdapter.kt @@ -7,7 +7,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide -import com.catchmate.domain.model.user.GetUserProfileResponse +import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.presentation.databinding.ItemChattingParticipantBinding import com.catchmate.presentation.interaction.OnKickOutClickListener @@ -16,11 +16,11 @@ class ChattingCrewListAdapter( private val writerId: Long, private val pageType: String, private val onKickOutClickListener: OnKickOutClickListener? = null, -) : ListAdapter(diffUtil) { +) : ListAdapter(diffUtil) { inner class CrewViewHolder( private val binding: ItemChattingParticipantBinding, ) : RecyclerView.ViewHolder(binding.root) { - fun bind(profile: GetUserProfileResponse) { + fun bind(profile: GetChattingCrewListResponse) { binding.apply { Glide .with(root) @@ -76,15 +76,15 @@ class ChattingCrewListAdapter( companion object { val diffUtil = - object : DiffUtil.ItemCallback() { + object : DiffUtil.ItemCallback() { override fun areItemsTheSame( - oldItem: GetUserProfileResponse, - newItem: GetUserProfileResponse, + oldItem: GetChattingCrewListResponse, + newItem: GetChattingCrewListResponse, ): Boolean = oldItem == newItem override fun areContentsTheSame( - oldItem: GetUserProfileResponse, - newItem: GetUserProfileResponse, + oldItem: GetChattingCrewListResponse, + newItem: GetChattingCrewListResponse, ): Boolean = oldItem == newItem } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt index c3197788..ab5f6233 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt @@ -3,6 +3,7 @@ package com.catchmate.presentation.view.chatting import android.os.Bundle import android.os.Handler import android.os.Looper +import android.os.Parcelable import android.text.Editable import android.text.TextWatcher import android.util.Log @@ -10,16 +11,14 @@ import android.view.View import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat -import androidx.core.os.bundleOf -import androidx.fragment.app.setFragmentResult import androidx.fragment.app.viewModels import androidx.navigation.NavOptions import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.catchmate.domain.model.chatting.ChatRoomInfo +import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.enumclass.ChatMessageType -import com.catchmate.domain.model.user.GetUserProfileResponse import com.catchmate.presentation.R import com.catchmate.presentation.databinding.FragmentChattingRoomBinding import com.catchmate.presentation.databinding.LayoutChattingSideSheetBinding @@ -40,7 +39,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC private val chattingRoomViewModel: ChattingRoomViewModel by viewModels() private val localDataViewModel: LocalDataViewModel by viewModels() private var userId: Long = -1L - private var lastChatMessageId: String? = null + private var lastMessageId: Long? = null private var isLastPage = false private var isLoading = false private var isApiCalled = false @@ -57,7 +56,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC super.onViewCreated(view, savedInstanceState) localDataViewModel.getUserId() initViewModel() - chattingRoomViewModel.getChattingRoomInfo(chatRoomId) +// chattingRoomViewModel.getChattingRoomInfo(chatRoomId) initChatBox() initSendBtn() onBackPressedAction = { setOnBackPressedAction() } @@ -70,52 +69,52 @@ class ChattingRoomFragment : BaseFragment(FragmentC } private fun initViewModel() { - chattingRoomViewModel.getChattingHistoryResponse.observe(viewLifecycleOwner) { response -> - if (response.isFirst && response.isLast && response.chatMessageInfoList.isEmpty()) { + chattingRoomViewModel.getChattingMessagesResponse.observe(viewLifecycleOwner) { response -> + if (response.isEmpty()) { Log.d("빈 채팅방 목록", "empty") } else { - Log.i("👀observer", "work \n ${response.chatMessageInfoList.size}") + Log.i("👀observer", "work \n ${response.size}") if (isApiCalled) { val currentList = chatListAdapter.currentList.toMutableList() Log.d("IS API CALLED", "🅾️") - currentList.addAll(response.chatMessageInfoList) + currentList.addAll(response) chatListAdapter.submitList(currentList) isApiCalled = false } else { - chatListAdapter.submitList(response.chatMessageInfoList) { + chatListAdapter.submitList(response) { // 수신 메시지 추가 후 콜백을 통해 최신 메시지로 스크롤 이동 binding.rvChattingRoomChatList.smoothScrollToPosition(0) isApiCalled = false } } - isLastPage = response.isLast + isLastPage = response.size < 20 isLoading = false } } chattingRoomViewModel.getChattingCrewListResponse.observe(viewLifecycleOwner) { response -> if (response != null) { - initRecyclerView(response.userInfoList) - } - } - chattingRoomViewModel.chattingRoomInfo.observe(viewLifecycleOwner) { info -> - if (info != null) { -// isNotificationEnabled = info.isNotificationEnabled - initChatRoomInfo(info) - initHeader(info) - } - } - chattingRoomViewModel.deleteChattingRoomResponse.observe(viewLifecycleOwner) { response -> - response?.let { - if (it.state) { - Log.d("채팅방 나가기 성공", "나가기 성공") - setFragmentResult("deleteChattingRoomResultKey", bundleOf("chatRoomId" to chatRoomId)) - findNavController().popBackStack() - } else { - Log.d("채팅방 오류", "나가기 실패") - showAlertSnackbar(R.string.chatting_leave_room_fail) - } + initRecyclerView(response) } } +// chattingRoomViewModel.chattingRoomInfo.observe(viewLifecycleOwner) { info -> +// if (info != null) { +//// isNotificationEnabled = info.isNotificationEnabled +// initChatRoomInfo(info) +// initHeader(info) +// } +// } +// chattingRoomViewModel.deleteChattingRoomResponse.observe(viewLifecycleOwner) { response -> +// response?.let { +// if (it.state) { +// Log.d("채팅방 나가기 성공", "나가기 성공") +// setFragmentResult("deleteChattingRoomResultKey", bundleOf("chatRoomId" to chatRoomId)) +// findNavController().popBackStack() +// } else { +// Log.d("채팅방 오류", "나가기 실패") +// showAlertSnackbar(R.string.chatting_leave_room_fail) +// } +// } +// } chattingRoomViewModel.navigateToLogin.observe(viewLifecycleOwner) { isTrue -> if (isTrue) { val navOptions = @@ -139,7 +138,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC chattingRoomViewModel.getChattingCrewList(chatRoomId) } localDataViewModel.accessToken.observe(viewLifecycleOwner) { token -> - chattingRoomViewModel.connectToWebSocket(chatRoomId, userId, token) + chattingRoomViewModel.connectToWebSocket(chatRoomId, token) } chattingRoomViewModel.isMessageSent.observe(viewLifecycleOwner) { isSent -> if (isSent) { @@ -155,7 +154,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC } } - private fun initRecyclerView(list: List) { + private fun initRecyclerView(list: List) { Log.i("userID", userId.toString()) chatListAdapter = ChatListAdapter(userId, list) binding.rvChattingRoomChatList.apply { @@ -179,7 +178,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC lastVisibleItemPosition >= 0 && lastVisibleItemPosition < chatListAdapter.currentList.size ) { - lastChatMessageId = chatListAdapter.currentList[lastVisibleItemPosition].chatMessageId + lastMessageId = chatListAdapter.currentList[lastVisibleItemPosition].messageId getChattingHistory() } } @@ -197,7 +196,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC Log.i("api 호출", "호출 $isLoading $isLastPage") if (isLoading || isLastPage) return isLoading = true - chattingRoomViewModel.getChattingHistory(chatRoomId, lastChatMessageId) + chattingRoomViewModel.getChattingMessages(chatRoomId, lastMessageId) isApiCalled = true } @@ -254,12 +253,11 @@ class ChattingRoomFragment : BaseFragment(FragmentC val message = JSONObject() .apply { - put("messageType", ChatMessageType.TALK.name) + put("chatRoomId", chatRoomId) put("content", binding.edtChattingRoomChatBox.text.toString()) - put("senderId", userId) + put("messageType", ChatMessageType.TEXT) }.toString() - - chattingRoomViewModel.sendMessage(chatRoomId, message) + chattingRoomViewModel.sendMessage(message) } } @@ -320,7 +318,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC adapter = crewAdapter layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) } - crewAdapter.submitList(chattingRoomViewModel.getChattingCrewListResponse.value?.userInfoList) + crewAdapter.submitList((chattingRoomViewModel.getChattingCrewListResponse.value ?: emptyList())) // 버튼 기능 ivSideSheetLeaveChattingRoom.setOnClickListener { @@ -334,7 +332,9 @@ class ChattingRoomFragment : BaseFragment(FragmentC val bundle = Bundle().apply { // putString("chattingRoomImage", info.chatRoomImage) - putParcelable("chattingCrewList", chattingRoomViewModel.getChattingCrewListResponse.value) + putParcelableArrayList("chattingCrewList", + chattingRoomViewModel.getChattingCrewListResponse.value as ArrayList? + ) putLong("loginUserId", userId) putLong("writerId", info.board.userResponse.userId) putLong("chatRoomId", chatRoomId) @@ -349,7 +349,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC toggleSideSheetChattingRoomNotification.setOnClickListener { isNotificationEnabled = !isNotificationEnabled toggleSideSheetChattingRoomNotification.isChecked = isNotificationEnabled - chattingRoomViewModel.putChattingRoomAlarm(chatRoomId, isNotificationEnabled) +// chattingRoomViewModel.putChattingRoomAlarm(chatRoomId, isNotificationEnabled) } layoutSideSheetPostInfo.setOnClickListener { val bundle = Bundle() @@ -397,7 +397,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC ContextCompat.getColor(requireContext(), R.color.brand500), ) setOnClickListener { - chattingRoomViewModel.deleteChattingRoom(chatRoomId) +// chattingRoomViewModel.deleteChattingRoom(chatRoomId) dialog.dismiss() } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt index 7650175f..81fdc4d5 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt @@ -17,7 +17,6 @@ import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.bumptech.glide.Glide import com.catchmate.domain.model.chatting.GetChattingCrewListResponse -import com.catchmate.domain.model.user.GetUserProfileResponse import com.catchmate.presentation.R import com.catchmate.presentation.databinding.FragmentChattingSettingBinding import com.catchmate.presentation.interaction.OnKickOutClickListener @@ -38,7 +37,7 @@ class ChattingSettingFragment : private lateinit var chattingCrewAdapter: ChattingCrewListAdapter private lateinit var chattingRoomImage: String - private lateinit var chattingCrewList: MutableList + private lateinit var chattingCrewList: MutableList private var loginUserId: Long = -1L private var writerId: Long = -1L private var chatRoomId: Long = -1L @@ -69,12 +68,12 @@ class ChattingSettingFragment : private fun getChattingRoomImage(): String = arguments?.getString("chattingRoomImage") ?: "" - private fun getChattingCrewList(): MutableList? = + private fun getChattingCrewList(): MutableList? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - arguments?.getParcelable("chattingCrewList", GetChattingCrewListResponse::class.java)?.userInfoList?.toMutableList() + arguments?.getParcelableArrayList("chattingCrewList", GetChattingCrewListResponse::class.java)?.toMutableList() } else { - val parcelable = arguments?.getParcelable("chattingCrewList") as GetChattingCrewListResponse? - parcelable?.userInfoList?.toMutableList() + val parcelable = arguments?.getParcelableArrayList("chattingCrewList") + parcelable?.toMutableList() } private fun getLoginUserId(): Long = arguments?.getLong("loginUserId") ?: -1L diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt index cebd5daf..72e1a823 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt @@ -6,21 +6,18 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.catchmate.domain.exception.ReissueFailureException -import com.catchmate.domain.model.chatting.ChatMessageId -import com.catchmate.domain.model.chatting.ChatMessageInfo import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse -import com.catchmate.domain.model.chatting.GetChattingHistoryResponse +import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse import com.catchmate.domain.model.enumclass.ChatMessageType import com.catchmate.domain.usecase.chatting.GetChattingCrewListUseCase -import com.catchmate.domain.usecase.chatting.GetChattingHistoryUseCase +import com.catchmate.domain.usecase.chatting.GetChattingMessagesUseCase import com.catchmate.domain.usecase.chatting.GetChattingRoomInfoUseCase import com.catchmate.domain.usecase.chatting.LeaveChattingRoomUseCase import com.catchmate.domain.usecase.chatting.PutChattingRoomAlarmUseCase import com.catchmate.presentation.BuildConfig -import com.catchmate.presentation.util.DateUtils.getCurrentTimeFormatted import dagger.hilt.android.lifecycle.HiltViewModel import io.reactivex.disposables.Disposable import kotlinx.coroutines.launch @@ -30,13 +27,14 @@ import org.json.JSONObject import ua.naiksoftware.stomp.Stomp import ua.naiksoftware.stomp.StompClient import ua.naiksoftware.stomp.dto.LifecycleEvent +import ua.naiksoftware.stomp.dto.StompHeader import javax.inject.Inject @HiltViewModel class ChattingRoomViewModel @Inject constructor( - private val getChattingHistoryUseCase: GetChattingHistoryUseCase, + private val getChattingMessagesUseCase: GetChattingMessagesUseCase, private val getChattingCrewListUseCase: GetChattingCrewListUseCase, private val getChattingRoomInfoUseCase: GetChattingRoomInfoUseCase, private val deleteChattingRoomUseCase: LeaveChattingRoomUseCase, @@ -46,12 +44,12 @@ class ChattingRoomViewModel var stompClient: StompClient? = null private var okHttpClient: OkHttpClient? = null - private val _getChattingHistoryResponse = MutableLiveData() - val getChattingHistoryResponse: LiveData - get() = _getChattingHistoryResponse + private val _getChattingMessagesResponse = MutableLiveData>() + val getChattingMessagesResponse: LiveData> + get() = _getChattingMessagesResponse - private val _getChattingCrewListResponse = MutableLiveData() - val getChattingCrewListResponse: LiveData + private val _getChattingCrewListResponse = MutableLiveData>() + val getChattingCrewListResponse: LiveData> get() = _getChattingCrewListResponse private val _chattingRoomInfo = MutableLiveData() @@ -85,7 +83,6 @@ class ChattingRoomViewModel /** WebSocket 연결 */ fun connectToWebSocket( chatRoomId: Long, - userId: Long, accessToken: String, ) { viewModelScope.launch { @@ -100,8 +97,7 @@ class ChattingRoomViewModel val headerMap = mapOf( - "AccessToken" to accessToken, - "ChatRoomId" to chatRoomId.toString(), + "Authorization" to accessToken, ) stompClient = @@ -116,13 +112,16 @@ class ChattingRoomViewModel withServerHeartbeat(35000) } - stompClient?.connect() + val stompHeaders = + listOf( + StompHeader("Authorization", accessToken) + ) stompClient?.lifecycle()?.subscribe({ event -> when (event.type) { LifecycleEvent.Type.OPENED -> { Log.d("Web Socket✅", "연결 성공") - handleWebSocketOpened(chatRoomId, userId) + handleWebSocketOpened(chatRoomId) } LifecycleEvent.Type.CLOSED -> { @@ -130,7 +129,7 @@ class ChattingRoomViewModel } LifecycleEvent.Type.ERROR -> { - Log.i("Web Socket", "${event.exception.message}") + Log.i("Web Socket", "${event.exception}") _isInstability.postValue(true) } @@ -140,56 +139,70 @@ class ChattingRoomViewModel Log.i("Web Socket", "${error.message}") _isInstability.postValue(true) }) + + stompClient?.connect(stompHeaders) } } private fun handleWebSocketOpened( chatRoomId: Long, - userId: Long, ) { // 채팅방 구독 topic = - stompClient?.topic("/topic/chat.$chatRoomId")?.subscribe({ message -> + stompClient?.topic("/sub/chat/room/$chatRoomId")?.subscribe({ message -> Log.i("✅ Msg", message.payload) val jsonObject = JSONObject(message.payload) val messageType = jsonObject.getString("messageType") - val chatMessageInfo: ChatMessageInfo = + val chatMessage: GetChattingMessagesResponse = when (messageType) { - ChatMessageType.DATE.name -> { - val roomId = jsonObject.getString("chatRoomId").toLong() +// ChatMessageType.DATE.name -> { +// val roomId = jsonObject.getString("chatRoomId").toLong() +// val content = jsonObject.getString("content") +// val senderId = jsonObject.getString("senderId").toLong() +// ChatMessageInfo( +// chatMessageId = "", +// roomId = roomId, +// content = content, +// senderId = senderId, +// messageType = messageType, +// ) +// } + + ChatMessageType.TEXT.name -> { + val messageId = jsonObject.getLong("messageId") + val roomId = jsonObject.getLong("roomId") + val senderId = jsonObject.getLong("senderId") + val senderNickname = jsonObject.getString("senderNickname") + val senderProfileImage = jsonObject.getString("senderProfileImage") val content = jsonObject.getString("content") - val senderId = jsonObject.getString("senderId").toLong() - ChatMessageInfo( - chatMessageId = "", - roomId = roomId, - content = content, + val createdAt = jsonObject.getString("createdAt") + GetChattingMessagesResponse( + messageId = messageId, + chatRoomId = roomId, senderId = senderId, - messageType = messageType, - ) - } - - ChatMessageType.TALK.name -> { - val chatMessageId = jsonObject.getString("chatMessageId") - val senderId = jsonObject.getString("senderId").toLong() - val content = jsonObject.getString("content") - val roomId = jsonObject.getString("roomId").toLong() - val id = ChatMessageId(date = getCurrentTimeFormatted()) - ChatMessageInfo( - id = id, - chatMessageId = chatMessageId, - roomId = roomId, + senderNickName = senderNickname, + senderProfileImageUrl = senderProfileImage, content = content, - senderId = senderId, messageType = messageType, + createdAt = createdAt, ) } else -> { // 채팅방 나가고 들어올때 메시지 처리하기 - ChatMessageInfo(chatMessageId = "", roomId = -1L, content = "", senderId = -1L, messageType = "") + GetChattingMessagesResponse( + messageId = -1, + chatRoomId = -1, + senderId = -1, + senderNickName = "", + senderProfileImageUrl = "", + content = "", + messageType = "", + createdAt = "", + ) } } - addChatMessage(chatMessageInfo) - sendIsMsgRead(chatRoomId, userId) + addChatMessage(chatMessage) + sendIsMsgRead(chatRoomId) }, { error -> Log.i("ws opened", "chatroom subscribe error / ${error.printStackTrace()}", error) }) @@ -197,26 +210,23 @@ class ChattingRoomViewModel private fun sendIsMsgRead( chatRoomId: Long, - userId: Long, ) { viewModelScope.launch { val msg = JSONObject() .apply { put("chatRoomId", chatRoomId) - put("userId", userId) }.toString() - stompClient?.send("/app/chat/read", msg)?.subscribe() + stompClient?.send("/pub/chat/read", msg)?.subscribe() } } fun sendMessage( - chatRoomId: Long, message: String, ) { // 전달 성공 시 view의 edt 텍스트 비우기 viewModelScope.launch { - stompClient?.send("/app/chat.$chatRoomId", message)?.subscribe({ + stompClient?.send("/pub/chat/message", message)?.subscribe({ Log.d("Web Socket📬", "메시지 전달") _isMessageSent.value = true }, { error -> @@ -232,33 +242,23 @@ class ChattingRoomViewModel stompClient?.disconnect() } - private fun addChatMessage(chatMessageInfo: ChatMessageInfo) { - val currentList = _getChattingHistoryResponse.value?.chatMessageInfoList ?: emptyList() - val updatedList = listOf(chatMessageInfo) + currentList - - val updatedResponse = - _getChattingHistoryResponse.value?.copy( - chatMessageInfoList = updatedList, - ) ?: GetChattingHistoryResponse( - chatMessageInfoList = updatedList, - isFirst = true, - isLast = true, - lastMessageId = updatedList.last().chatMessageId, - ) + private fun addChatMessage(chatMessage: GetChattingMessagesResponse) { + val currentList = _getChattingMessagesResponse.value ?: emptyList() + val updatedList = listOf(chatMessage) + currentList - _getChattingHistoryResponse.postValue(updatedResponse) + _getChattingMessagesResponse.postValue(updatedList) } - fun getChattingHistory( + fun getChattingMessages( chatRoomId: Long, - lastMessageId: String? = null, - size: Int? = 20, + lastMessageId: Long? = null, + size: Int = 20, ) { viewModelScope.launch { - val result = getChattingHistoryUseCase(chatRoomId, lastMessageId, size) + val result = getChattingMessagesUseCase(chatRoomId, lastMessageId, size) result .onSuccess { response -> - _getChattingHistoryResponse.value = response + _getChattingMessagesResponse.value = response }.onFailure { exception -> if (exception is ReissueFailureException) { _navigateToLogin.value = true @@ -285,54 +285,54 @@ class ChattingRoomViewModel } } - fun getChattingRoomInfo(chatRoomId: Long) { - viewModelScope.launch { - val result = getChattingRoomInfoUseCase(chatRoomId) - result - .onSuccess { info -> - _chattingRoomInfo.value = info - }.onFailure { exception -> - if (exception is ReissueFailureException) { - _navigateToLogin.value = true - } else { - _errorMessage.value = exception.message - } - } - } - } - - fun deleteChattingRoom(chatRoomId: Long) { - viewModelScope.launch { - val result = deleteChattingRoomUseCase(chatRoomId) - result - .onSuccess { response -> - _deleteChattingRoomResponse.value = response - }.onFailure { exception -> - if (exception is ReissueFailureException) { - _navigateToLogin.value = true - } else { - _errorMessage.value = exception.message - } - } - } - } - - fun putChattingRoomAlarm( - chatRoomId: Long, - enable: Boolean, - ) { - viewModelScope.launch { - val result = putChattingRoomAlarmUseCase(chatRoomId, enable) - result - .onSuccess { response -> - _putChattingRoomAlarmResponse.value = response - }.onFailure { exception -> - if (exception is ReissueFailureException) { - _navigateToLogin.value = true - } else { - _errorMessage.value = exception.message - } - } - } - } +// fun getChattingRoomInfo(chatRoomId: Long) { +// viewModelScope.launch { +// val result = getChattingRoomInfoUseCase(chatRoomId) +// result +// .onSuccess { info -> +// _chattingRoomInfo.value = info +// }.onFailure { exception -> +// if (exception is ReissueFailureException) { +// _navigateToLogin.value = true +// } else { +// _errorMessage.value = exception.message +// } +// } +// } +// } +// +// fun deleteChattingRoom(chatRoomId: Long) { +// viewModelScope.launch { +// val result = deleteChattingRoomUseCase(chatRoomId) +// result +// .onSuccess { response -> +// _deleteChattingRoomResponse.value = response +// }.onFailure { exception -> +// if (exception is ReissueFailureException) { +// _navigateToLogin.value = true +// } else { +// _errorMessage.value = exception.message +// } +// } +// } +// } +// +// fun putChattingRoomAlarm( +// chatRoomId: Long, +// enable: Boolean, +// ) { +// viewModelScope.launch { +// val result = putChattingRoomAlarmUseCase(chatRoomId, enable) +// result +// .onSuccess { response -> +// _putChattingRoomAlarmResponse.value = response +// }.onFailure { exception -> +// if (exception is ReissueFailureException) { +// _navigateToLogin.value = true +// } else { +// _errorMessage.value = exception.message +// } +// } +// } +// } } From 045c6ba9d76fcd778b3f49350429c52daed34540 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Mon, 23 Feb 2026 17:36:47 +0900 Subject: [PATCH 04/14] =?UTF-8?q?refactor:=20=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EA=B4=80=EB=A0=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 채팅방 내 boardInfo 표시 - side sheet crew list 표시 - 채팅방 나가기 소켓 통신 - 채팅방 최초 입장 알림 소켓 통신 및 판별 로직 구현 --- .../data/datasource/remote/ChattingService.kt | 15 +--- .../catchmate/data/mapper/ChattingMapper.kt | 10 +-- .../data/repository/ChattingRepositoryImpl.kt | 21 ++--- .../domain/model/chatting/ChatRoomInfo.kt | 6 +- .../domain/model/chatting/LastMessageInfo.kt | 6 +- .../domain/model/enumclass/ChatMessageType.kt | 4 +- .../domain/repository/ChattingRepository.kt | 6 +- .../chatting/GetChattingRoomInfoUseCase.kt | 13 --- .../chatting/LeaveChattingRoomUseCase.kt | 4 +- .../OnChattingRoomSelectedListener.kt | 7 +- .../view/chatting/ChatListAdapter.kt | 21 ++--- .../view/chatting/ChattingHomeFragment.kt | 52 +++++------ .../view/chatting/ChattingRoomFragment.kt | 83 +++++++++++------- .../view/chatting/ChattingRoomListAdapter.kt | 2 +- .../viewmodel/ChattingHomeViewModel.kt | 39 ++++----- .../viewmodel/ChattingRoomViewModel.kt | 86 ++++++++++--------- 16 files changed, 176 insertions(+), 199 deletions(-) delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingRoomInfoUseCase.kt diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt index 38dd16bf..effc071c 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt @@ -1,8 +1,6 @@ package com.catchmate.data.datasource.remote -import com.catchmate.data.dto.chatting.ChatRoomInfoDTO import com.catchmate.data.dto.chatting.DeleteChattingCrewKickOutResponseDTO -import com.catchmate.data.dto.chatting.DeleteChattingRoomResponseDTO import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO @@ -31,11 +29,6 @@ interface ChattingService { @Path("chatRoomId") chatRoomId: Long, ): Response?> - @GET("chat-rooms/{chatRoomId}") - suspend fun getChattingRoomInfo( - @Path("chatRoomId") chatRoomId: Long, - ): Response - @Multipart @PATCH("chat-rooms/{chatRoomId}/image") suspend fun patchChattingRoomImage( @@ -49,10 +42,10 @@ interface ChattingService { @Query("enable") enable: Boolean, ): Response - @DELETE("chat-rooms/{chatRoomId}") - suspend fun deleteChattingRoom( - @Path("chatRoomId") chatRoomId: Long, - ): Response +// @DELETE("chat-rooms/{chatRoomId}") +// suspend fun deleteChattingRoom( +// @Path("chatRoomId") chatRoomId: Long, +// ): Response @DELETE("chat-rooms/{chatRoomId}/users/{userId}") suspend fun deleteChattingCrewKickOut( diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index c1f87b91..e507091a 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -2,7 +2,6 @@ package com.catchmate.data.mapper import com.catchmate.data.dto.chatting.ChatRoomInfoDTO import com.catchmate.data.dto.chatting.DeleteChattingCrewKickOutResponseDTO -import com.catchmate.data.dto.chatting.DeleteChattingRoomResponseDTO import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO @@ -12,7 +11,6 @@ import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO import com.catchmate.data.mapper.BoardMapper.toBoard import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse -import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse @@ -74,10 +72,10 @@ object ChattingMapper { joinedAt = dto.joinedAt, ) - fun toDeleteChattingRoomResponse(dto: DeleteChattingRoomResponseDTO): DeleteChattingRoomResponse = - DeleteChattingRoomResponse( - state = dto.state, - ) +// fun toDeleteChattingRoomResponse(dto: DeleteChattingRoomResponseDTO): DeleteChattingRoomResponse = +// DeleteChattingRoomResponse( +// state = dto.state, +// ) fun toDeleteChattingCrewKickOutResponse(dto: DeleteChattingCrewKickOutResponseDTO): DeleteChattingCrewKickOutResponse = DeleteChattingCrewKickOutResponse( diff --git a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt index 021a359a..c83b1eea 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt @@ -4,9 +4,7 @@ import com.catchmate.data.datasource.remote.ChattingService import com.catchmate.data.datasource.remote.RetrofitClient import com.catchmate.data.mapper.ChattingMapper import com.catchmate.data.util.ApiResponseHandleUtil.apiCall -import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse -import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse @@ -45,13 +43,6 @@ class ChattingRepositoryImpl }, ) - override suspend fun getChattingRoomInfo(chatRoomId: Long): Result = - apiCall( - tag = this.tag, - apiFunction = { chattingApi.getChattingRoomInfo(chatRoomId) }, - transform = { ChattingMapper.toChatRoomInfo(it!!) }, - ) - override suspend fun patchChattingRoomImage( chatRoomId: Long, chatRoomImage: MultipartBody.Part, @@ -72,12 +63,12 @@ class ChattingRepositoryImpl transform = { ChattingMapper.toPutChattingRoomAlarmResponse(it!!) }, ) - override suspend fun deleteChattingRoom(chatRoomId: Long): Result = - apiCall( - tag = this.tag, - apiFunction = { chattingApi.deleteChattingRoom(chatRoomId) }, - transform = { ChattingMapper.toDeleteChattingRoomResponse(it!!) }, - ) +// override suspend fun deleteChattingRoom(chatRoomId: Long): Result = +// apiCall( +// tag = this.tag, +// apiFunction = { chattingApi.deleteChattingRoom(chatRoomId) }, +// transform = { ChattingMapper.toDeleteChattingRoomResponse(it!!) }, +// ) override suspend fun deleteChattingCrewKickOut( chatRoomId: Long, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt index 55d15bd1..7e738656 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt @@ -1,11 +1,15 @@ package com.catchmate.domain.model.chatting +import android.os.Parcel +import android.os.Parcelable import com.catchmate.domain.model.board.Board +import kotlinx.parcelize.Parcelize +@Parcelize data class ChatRoomInfo( val chatRoomId: Long, val board: Board, val lastMessage: LastMessageInfo?, val unreadCount: Long, val createdAt: String, -) +) : Parcelable diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/LastMessageInfo.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/LastMessageInfo.kt index 55c88a63..14d612e3 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/LastMessageInfo.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/LastMessageInfo.kt @@ -1,5 +1,9 @@ package com.catchmate.domain.model.chatting +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize data class LastMessageInfo( val messageId: Long, val chatRoomId: Long, @@ -9,4 +13,4 @@ data class LastMessageInfo( val content: String, val messageType: String, val createdAt: String, -) +) : Parcelable diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt index 30f30edb..67976507 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/enumclass/ChatMessageType.kt @@ -1,9 +1,7 @@ package com.catchmate.domain.model.enumclass enum class ChatMessageType { - TALK, DATE, - ENTER, - LEAVE, + SYSTEM, TEXT, } diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt index 1a88c6ac..7ee85380 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt @@ -1,8 +1,6 @@ package com.catchmate.domain.repository -import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse -import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse @@ -18,8 +16,6 @@ interface ChattingRepository { suspend fun getChattingCrewList(chatRoomId: Long): Result> - suspend fun getChattingRoomInfo(chatRoomId: Long): Result - suspend fun patchChattingRoomImage( chatRoomId: Long, chatRoomImage: MultipartBody.Part, @@ -30,7 +26,7 @@ interface ChattingRepository { enable: Boolean, ): Result - suspend fun deleteChattingRoom(chatRoomId: Long): Result +// suspend fun deleteChattingRoom(chatRoomId: Long): Result suspend fun deleteChattingCrewKickOut( chatRoomId: Long, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingRoomInfoUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingRoomInfoUseCase.kt deleted file mode 100644 index 5a175061..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/GetChattingRoomInfoUseCase.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.catchmate.domain.usecase.chatting - -import com.catchmate.domain.model.chatting.ChatRoomInfo -import com.catchmate.domain.repository.ChattingRepository -import javax.inject.Inject - -class GetChattingRoomInfoUseCase - @Inject - constructor( - private val chattingRepository: ChattingRepository, - ) { - suspend operator fun invoke(chatRoomId: Long): Result = chattingRepository.getChattingRoomInfo(chatRoomId) - } diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt index a71c4a42..458acb3a 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt @@ -9,6 +9,6 @@ class LeaveChattingRoomUseCase constructor( private val chattingRepository: ChattingRepository, ) { - suspend operator fun invoke(chatRoomId: Long): Result = - chattingRepository.deleteChattingRoom(chatRoomId) +// suspend operator fun invoke(chatRoomId: Long): Result = +// chattingRepository.deleteChattingRoom(chatRoomId) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/interaction/OnChattingRoomSelectedListener.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/interaction/OnChattingRoomSelectedListener.kt index a4d3f1fe..3a90775c 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/interaction/OnChattingRoomSelectedListener.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/interaction/OnChattingRoomSelectedListener.kt @@ -1,8 +1,7 @@ package com.catchmate.presentation.interaction +import com.catchmate.domain.model.chatting.ChatRoomInfo + interface OnChattingRoomSelectedListener { - fun onChattingRoomSelected( - chatRoomId: Long, - isNewChatRoom: Boolean, - ) + fun onChattingRoomSelected(chatRoomInfo: ChatRoomInfo) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt index 08016416..01fa45c5 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt @@ -78,15 +78,7 @@ class ChatListAdapter( chat: GetChattingMessagesResponse, viewType: Int, ) { - val nickname = - chattingCrewList.firstOrNull { it.userId == chat.senderId }?.nickName ?: "알수없음" - val message = - if (viewType == ENTER) { - "$nickname 님이 채팅에 참여했어요" - } else { - "$nickname 님이 나갔어요" - } - binding.tvChattingParticipantAlert.text = message + binding.tvChattingParticipantAlert.text = chat.content } } @@ -144,7 +136,7 @@ class ChatListAdapter( MY_CHAT -> (holder as SendChatViewHolder).bind(currentList[position]) OTHER_CHAT -> (holder as ReceivedChatViewHolder).bind(currentList[position]) DATE -> (holder as ChattingDateViewHolder).bind(currentList[position]) - ENTER, LEAVE -> (holder as ChattingParticipantViewHolder).bind(currentList[position], getItemViewType(position)) + SYSTEM -> (holder as ChattingParticipantViewHolder).bind(currentList[position], getItemViewType(position)) } } @@ -162,12 +154,12 @@ class ChatListAdapter( DATE } - ChatMessageType.ENTER.name -> { - ENTER + ChatMessageType.SYSTEM.name -> { + SYSTEM } else -> { - LEAVE + SYSTEM } } @@ -188,7 +180,6 @@ class ChatListAdapter( private const val MY_CHAT = 1 private const val OTHER_CHAT = 2 private const val DATE = 3 - private const val ENTER = 4 - private const val LEAVE = 5 + private const val SYSTEM = 4 } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt index 0ed6befb..ba728fc3 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide +import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.presentation.R import com.catchmate.presentation.databinding.FragmentChattingHomeBinding import com.catchmate.presentation.databinding.LayoutAlertDialogBinding @@ -52,28 +53,20 @@ class ChattingHomeFragment : initHeader() initRecyclerView() initViewModel() - - if (isFirstLoad) { - getChattingRoomList() - isFirstLoad = false - } // (requireActivity() as MainActivity).refreshNotificationStatus() } override fun onResume() { super.onResume() - // 화면이 다시 보일 때만 새로고침 (최초 실행 시에는 제외) - if (!isFirstLoad) { - Log.d("ChattingHomeFragment", "onResume: 채팅방 목록 새로고침") - // 페이지 초기화 - currentPage = 0 - hasNext = true - isLoading = false - - chattingRoomListAdapter.submitList(emptyList()) - // 채팅방 목록 새로 불러오기 - getChattingRoomList() - } + Log.d("ChattingHomeFragment", "onResume: 채팅방 목록 새로고침") + // 페이지 초기화 + currentPage = 0 + hasNext = true + isLoading = false + + chattingRoomListAdapter.submitList(emptyList()) + // 채팅방 목록 새로 불러오기 + getChattingRoomList() } override fun onDestroyView() { @@ -139,13 +132,13 @@ class ChattingHomeFragment : } } } - chattingHomeViewModel.leaveChattingRoomResponse.observe(viewLifecycleOwner) { response -> - if (response.state) { - chattingRoomListAdapter.removeItem(deletedItemPos) - } else { - Snackbar.make(requireView(), R.string.chatting_leave_room_fail, Snackbar.LENGTH_SHORT).show() - } - } +// chattingHomeViewModel.leaveChattingRoomResponse.observe(viewLifecycleOwner) { response -> +// if (response.state) { +// chattingRoomListAdapter.removeItem(deletedItemPos) +// } else { +// Snackbar.make(requireView(), R.string.chatting_leave_room_fail, Snackbar.LENGTH_SHORT).show() +// } +// } } private fun initRecyclerView() { @@ -214,14 +207,11 @@ class ChattingHomeFragment : dialog.show() } - override fun onChattingRoomSelected( - chatRoomId: Long, - isNewChatRoom: Boolean, - ) { + override fun onChattingRoomSelected(chatRoomInfo: ChatRoomInfo) { val bundle = Bundle() - bundle.putLong("chatRoomId", chatRoomId) + bundle.putParcelable("chatRoomInfo", chatRoomInfo) findNavController().navigate(R.id.action_chattingHomeFragment_to_chattingRoomFragment, bundle) - if (isNewChatRoom) { + if (chatRoomInfo.lastMessage == null) { showChattingSystemAlertDialog() } } @@ -231,7 +221,7 @@ class ChattingHomeFragment : swipedItemId: Long, ) { deletedItemPos = position - chattingHomeViewModel.leaveChattingRoom(swipedItemId) +// chattingHomeViewModel.leaveChattingRoom(swipedItemId) } override fun onListItemAllRemoved() { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt index ab5f6233..89426835 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt @@ -1,5 +1,6 @@ package com.catchmate.presentation.view.chatting +import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper @@ -11,6 +12,8 @@ import android.view.View import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat +import androidx.core.os.bundleOf +import androidx.fragment.app.setFragmentResult import androidx.fragment.app.viewModels import androidx.navigation.NavOptions import androidx.navigation.fragment.findNavController @@ -33,6 +36,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.sidesheet.SideSheetDialog import dagger.hilt.android.AndroidEntryPoint import org.json.JSONObject +import kotlin.lazy @AndroidEntryPoint class ChattingRoomFragment : BaseFragment(FragmentChattingRoomBinding::inflate) { @@ -44,9 +48,9 @@ class ChattingRoomFragment : BaseFragment(FragmentC private var isLoading = false private var isApiCalled = false private var isFirstLoad = true - private val chatRoomId by lazy { arguments?.getLong("chatRoomId") ?: -1L } private val isPendingIntent by lazy { arguments?.getBoolean("isPendingIntent") ?: false } private var isNotificationEnabled = false + private lateinit var chatRoomInfo: ChatRoomInfo private lateinit var chatListAdapter: ChatListAdapter override fun onViewCreated( @@ -56,7 +60,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC super.onViewCreated(view, savedInstanceState) localDataViewModel.getUserId() initViewModel() -// chattingRoomViewModel.getChattingRoomInfo(chatRoomId) + getChatRoomInfo() initChatBox() initSendBtn() onBackPressedAction = { setOnBackPressedAction() } @@ -68,6 +72,19 @@ class ChattingRoomFragment : BaseFragment(FragmentC chattingRoomViewModel.stompClient?.disconnect() } + private fun getChatRoomInfo() { + val chatRoomInfo = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + arguments?.getParcelable("chatRoomInfo", ChatRoomInfo::class.java) + } else { + arguments?.getParcelable("chatRoomInfo") + } + chatRoomInfo?.let { info -> + chattingRoomViewModel.setChatRoomInfo(info) + } + } + + private fun initViewModel() { chattingRoomViewModel.getChattingMessagesResponse.observe(viewLifecycleOwner) { response -> if (response.isEmpty()) { @@ -96,25 +113,13 @@ class ChattingRoomFragment : BaseFragment(FragmentC initRecyclerView(response) } } -// chattingRoomViewModel.chattingRoomInfo.observe(viewLifecycleOwner) { info -> -// if (info != null) { -//// isNotificationEnabled = info.isNotificationEnabled -// initChatRoomInfo(info) -// initHeader(info) -// } -// } -// chattingRoomViewModel.deleteChattingRoomResponse.observe(viewLifecycleOwner) { response -> -// response?.let { -// if (it.state) { -// Log.d("채팅방 나가기 성공", "나가기 성공") -// setFragmentResult("deleteChattingRoomResultKey", bundleOf("chatRoomId" to chatRoomId)) -// findNavController().popBackStack() -// } else { -// Log.d("채팅방 오류", "나가기 실패") -// showAlertSnackbar(R.string.chatting_leave_room_fail) -// } -// } -// } + chattingRoomViewModel.chattingRoomInfo.observe(viewLifecycleOwner) { info -> + if (info != null) { +// isNotificationEnabled = info.isNotificationEnabled + initChatRoomInfo(info) + initHeader(info) + } + } chattingRoomViewModel.navigateToLogin.observe(viewLifecycleOwner) { isTrue -> if (isTrue) { val navOptions = @@ -135,10 +140,10 @@ class ChattingRoomFragment : BaseFragment(FragmentC localDataViewModel.userId.observe(viewLifecycleOwner) { id -> userId = id localDataViewModel.getAccessToken() - chattingRoomViewModel.getChattingCrewList(chatRoomId) + chattingRoomViewModel.getChattingCrewList(chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1) } localDataViewModel.accessToken.observe(viewLifecycleOwner) { token -> - chattingRoomViewModel.connectToWebSocket(chatRoomId, token) + chattingRoomViewModel.connectToWebSocket(chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1, token) } chattingRoomViewModel.isMessageSent.observe(viewLifecycleOwner) { isSent -> if (isSent) { @@ -147,6 +152,17 @@ class ChattingRoomFragment : BaseFragment(FragmentC showAlertSnackbar(R.string.chatting_message_send_fail) } } + chattingRoomViewModel.isLeft.observe(viewLifecycleOwner) { isSent -> + if (isSent) { + Log.d("채팅방 나가기 성공", "나가기 성공") + val chatRoomId = chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1 + setFragmentResult("deleteChattingRoomResultKey", bundleOf("chatRoomId" to chatRoomId)) + findNavController().popBackStack() + } else { + Log.d("채팅방 오류", "나가기 실패") + showAlertSnackbar(R.string.chatting_leave_room_fail) + } + } chattingRoomViewModel.isInstability.observe(viewLifecycleOwner) { isTrue -> if (isTrue) { showAlertSnackbar(R.string.chatting_connect_instability) @@ -196,7 +212,11 @@ class ChattingRoomFragment : BaseFragment(FragmentC Log.i("api 호출", "호출 $isLoading $isLastPage") if (isLoading || isLastPage) return isLoading = true - chattingRoomViewModel.getChattingMessages(chatRoomId, lastMessageId) + chattingRoomViewModel.getChattingMessages( + chatRoomId = chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1, + lastMessageId = lastMessageId, + userId = userId, + ) isApiCalled = true } @@ -250,14 +270,14 @@ class ChattingRoomFragment : BaseFragment(FragmentC private fun initSendBtn() { binding.btnChattingRoomChatBoxSend.setOnClickListener { - val message = + val request = JSONObject() .apply { - put("chatRoomId", chatRoomId) + put("chatRoomId", chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1) put("content", binding.edtChattingRoomChatBox.text.toString()) put("messageType", ChatMessageType.TEXT) }.toString() - chattingRoomViewModel.sendMessage(message) + chattingRoomViewModel.sendMessage(request) } } @@ -337,7 +357,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC ) putLong("loginUserId", userId) putLong("writerId", info.board.userResponse.userId) - putLong("chatRoomId", chatRoomId) + putLong("chatRoomId", chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1) } findNavController().navigate(R.id.action_chattingRoomFragment_to_chattingSettingFragment, bundle) sideSheetDialog.dismiss() @@ -397,7 +417,12 @@ class ChattingRoomFragment : BaseFragment(FragmentC ContextCompat.getColor(requireContext(), R.color.brand500), ) setOnClickListener { -// chattingRoomViewModel.deleteChattingRoom(chatRoomId) + val request = + JSONObject() + .apply { + put("chatRoomId", chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1) + }.toString() + chattingRoomViewModel.leaveChattingRoom(request) dialog.dismiss() } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt index ec92c5c6..8bfbee05 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt @@ -47,7 +47,7 @@ class ChattingRoomListAdapter( fun bind(chatRoomInfo: ChatRoomInfo) { binding.apply { root.setOnClickListener { - onChattingRoomSelectedListener.onChattingRoomSelected(chatRoomInfo.chatRoomId, chatRoomInfo.lastMessage == null) + onChattingRoomSelectedListener.onChattingRoomSelected(chatRoomInfo) } // 채팅방 이미지가 변경된 적 없는 경우 chatRoomImage에 cheerTeamId가 String으로 담겨옴 // 해당 변수를 int로 변환할 때 예외 처리를 통해 변경된 적 있을 경우의 imageUrl을 imageView에 표시 diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt index 653327d5..b7cc0be5 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt @@ -8,7 +8,6 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.catchmate.domain.exception.ReissueFailureException -import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse import com.catchmate.domain.model.chatting.LastMessageInfo import com.catchmate.domain.usecase.chatting.GetChattingRoomListUseCase @@ -41,9 +40,9 @@ class ChattingHomeViewModel val getChattingRoomListResponse: LiveData get() = _getChattingRoomListResponse - private val _leaveChattingRoomResponse = MutableLiveData() - val leaveChattingRoomResponse: LiveData - get() = _leaveChattingRoomResponse +// private val _leaveChattingRoomResponse = MutableLiveData() +// val leaveChattingRoomResponse: LiveData +// get() = _leaveChattingRoomResponse private val _errorMessage = MutableLiveData() val errorMessage: LiveData @@ -158,20 +157,20 @@ class ChattingHomeViewModel } } - fun leaveChattingRoom(chatRoomId: Long) { - viewModelScope.launch { - val result = leaveChattingRoomUseCase(chatRoomId) - result - .onSuccess { response -> - _leaveChattingRoomResponse.value = response - }.onFailure { exception -> - if (exception is ReissueFailureException) { - _navigateToLogin.value = true - } else { - Log.d("ChattingHomeVM", exception.message.toString()) - _errorMessage.value = "LeaveChattingRoomError" - } - } - } - } +// fun leaveChattingRoom(chatRoomId: Long) { +// viewModelScope.launch { +// val result = leaveChattingRoomUseCase(chatRoomId) +// result +// .onSuccess { response -> +// _leaveChattingRoomResponse.value = response +// }.onFailure { exception -> +// if (exception is ReissueFailureException) { +// _navigateToLogin.value = true +// } else { +// Log.d("ChattingHomeVM", exception.message.toString()) +// _errorMessage.value = "LeaveChattingRoomError" +// } +// } +// } +// } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt index 72e1a823..cf894423 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt @@ -7,15 +7,12 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.catchmate.domain.exception.ReissueFailureException import com.catchmate.domain.model.chatting.ChatRoomInfo -import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse import com.catchmate.domain.model.enumclass.ChatMessageType import com.catchmate.domain.usecase.chatting.GetChattingCrewListUseCase import com.catchmate.domain.usecase.chatting.GetChattingMessagesUseCase -import com.catchmate.domain.usecase.chatting.GetChattingRoomInfoUseCase -import com.catchmate.domain.usecase.chatting.LeaveChattingRoomUseCase import com.catchmate.domain.usecase.chatting.PutChattingRoomAlarmUseCase import com.catchmate.presentation.BuildConfig import dagger.hilt.android.lifecycle.HiltViewModel @@ -36,8 +33,6 @@ class ChattingRoomViewModel constructor( private val getChattingMessagesUseCase: GetChattingMessagesUseCase, private val getChattingCrewListUseCase: GetChattingCrewListUseCase, - private val getChattingRoomInfoUseCase: GetChattingRoomInfoUseCase, - private val deleteChattingRoomUseCase: LeaveChattingRoomUseCase, private val putChattingRoomAlarmUseCase: PutChattingRoomAlarmUseCase, ) : ViewModel() { var topic: Disposable? = null @@ -56,9 +51,9 @@ class ChattingRoomViewModel val chattingRoomInfo: LiveData get() = _chattingRoomInfo - private val _deleteChattingRoomResponse = MutableLiveData() - val deleteChattingRoomResponse: LiveData - get() = _deleteChattingRoomResponse + private val _isLeft = MutableLiveData() + val isLeft: LiveData + get() = _isLeft private val _putChattingRoomAlarmResponse = MutableLiveData() val putChattingRoomAlarmResponse: LiveData @@ -80,6 +75,10 @@ class ChattingRoomViewModel val isInstability: LiveData get() = _isInstability + fun setChatRoomInfo(info: ChatRoomInfo) { + _chattingRoomInfo.value = info + } + /** WebSocket 연결 */ fun connectToWebSocket( chatRoomId: Long, @@ -222,11 +221,11 @@ class ChattingRoomViewModel } fun sendMessage( - message: String, + request: String, ) { // 전달 성공 시 view의 edt 텍스트 비우기 viewModelScope.launch { - stompClient?.send("/pub/chat/message", message)?.subscribe({ + stompClient?.send("/pub/chat/message", request)?.subscribe({ Log.d("Web Socket📬", "메시지 전달") _isMessageSent.value = true }, { error -> @@ -236,6 +235,33 @@ class ChattingRoomViewModel } } + fun leaveChattingRoom(request: String) { + viewModelScope.launch { + stompClient?.send("/pub/chat/leave", request)?.subscribe({ + Log.d("Web Socket🚪", "방 탈퇴") + _isLeft.value = true + }, { error -> + Log.d("Web Socket🚪❌", "방 탈퇴 실패", error) + _isLeft.value = false + }) + } + } + + fun sendEnterRequest(chatRoomId: Long) { + viewModelScope.launch { + val request = + JSONObject() + .apply { + put("chatRoomId", chatRoomId) + }.toString() + stompClient?.send("/pub/chat/enter", request)?.subscribe({ + Log.d("Web Socket🪟", "입장 알림 성공") + }, { error -> + Log.d("Web Socket🪟❌", "입장 알림 실패", error) + }) + } + } + override fun onCleared() { super.onCleared() topic?.dispose() @@ -253,12 +279,20 @@ class ChattingRoomViewModel chatRoomId: Long, lastMessageId: Long? = null, size: Int = 20, + userId: Long, ) { viewModelScope.launch { val result = getChattingMessagesUseCase(chatRoomId, lastMessageId, size) result .onSuccess { response -> _getChattingMessagesResponse.value = response + val hasEnterMsg = + response.any { + it.messageType == "SYSTEM" && it.senderId == userId + } + if (response.isEmpty() || !hasEnterMsg) { + sendEnterRequest(chatRoomId) + } }.onFailure { exception -> if (exception is ReissueFailureException) { _navigateToLogin.value = true @@ -284,38 +318,6 @@ class ChattingRoomViewModel } } } - -// fun getChattingRoomInfo(chatRoomId: Long) { -// viewModelScope.launch { -// val result = getChattingRoomInfoUseCase(chatRoomId) -// result -// .onSuccess { info -> -// _chattingRoomInfo.value = info -// }.onFailure { exception -> -// if (exception is ReissueFailureException) { -// _navigateToLogin.value = true -// } else { -// _errorMessage.value = exception.message -// } -// } -// } -// } -// -// fun deleteChattingRoom(chatRoomId: Long) { -// viewModelScope.launch { -// val result = deleteChattingRoomUseCase(chatRoomId) -// result -// .onSuccess { response -> -// _deleteChattingRoomResponse.value = response -// }.onFailure { exception -> -// if (exception is ReissueFailureException) { -// _navigateToLogin.value = true -// } else { -// _errorMessage.value = exception.message -// } -// } -// } -// } // // fun putChattingRoomAlarm( // chatRoomId: Long, From 94a4bd6513b4418a132d16276670717c1bb8e8cc Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 17:27:57 +0900 Subject: [PATCH 05/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=ED=87=B4=EC=9E=A5=20api=20=EC=88=98=EC=A0=95=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/remote/ChattingService.kt | 8 ++-- .../chatting/DeleteChattingRoomResponseDTO.kt | 5 --- .../catchmate/data/mapper/ChattingMapper.kt | 5 --- .../data/repository/ChattingRepositoryImpl.kt | 12 +++--- .../chatting/DeleteChattingRoomResponse.kt | 5 --- .../domain/repository/ChattingRepository.kt | 2 +- .../chatting/LeaveChattingRoomUseCase.kt | 5 +-- .../view/chatting/ChattingHomeFragment.kt | 14 +++---- .../viewmodel/ChattingHomeViewModel.kt | 38 +++++++++---------- 9 files changed, 37 insertions(+), 57 deletions(-) delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingRoomResponseDTO.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingRoomResponse.kt diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt index effc071c..14143cbb 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt @@ -42,10 +42,10 @@ interface ChattingService { @Query("enable") enable: Boolean, ): Response -// @DELETE("chat-rooms/{chatRoomId}") -// suspend fun deleteChattingRoom( -// @Path("chatRoomId") chatRoomId: Long, -// ): Response + @DELETE("api/chat/rooms/{roomId}") + suspend fun deleteChattingRoom( + @Path("roomId") roomId: Long, + ): Response @DELETE("chat-rooms/{chatRoomId}/users/{userId}") suspend fun deleteChattingCrewKickOut( diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingRoomResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingRoomResponseDTO.kt deleted file mode 100644 index 562fc54b..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingRoomResponseDTO.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class DeleteChattingRoomResponseDTO( - val state: Boolean, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index e507091a..3ada7861 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -72,11 +72,6 @@ object ChattingMapper { joinedAt = dto.joinedAt, ) -// fun toDeleteChattingRoomResponse(dto: DeleteChattingRoomResponseDTO): DeleteChattingRoomResponse = -// DeleteChattingRoomResponse( -// state = dto.state, -// ) - fun toDeleteChattingCrewKickOutResponse(dto: DeleteChattingCrewKickOutResponseDTO): DeleteChattingCrewKickOutResponse = DeleteChattingCrewKickOutResponse( state = dto.state, diff --git a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt index c83b1eea..09f736dc 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt @@ -63,12 +63,12 @@ class ChattingRepositoryImpl transform = { ChattingMapper.toPutChattingRoomAlarmResponse(it!!) }, ) -// override suspend fun deleteChattingRoom(chatRoomId: Long): Result = -// apiCall( -// tag = this.tag, -// apiFunction = { chattingApi.deleteChattingRoom(chatRoomId) }, -// transform = { ChattingMapper.toDeleteChattingRoomResponse(it!!) }, -// ) + override suspend fun deleteChattingRoom(roomId: Long): Result = + apiCall( + tag = this.tag, + apiFunction = { chattingApi.deleteChattingRoom(roomId) }, + transform = { it }, + ) override suspend fun deleteChattingCrewKickOut( chatRoomId: Long, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingRoomResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingRoomResponse.kt deleted file mode 100644 index 33b6a57e..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingRoomResponse.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class DeleteChattingRoomResponse( - val state: Boolean, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt index 7ee85380..5cfffeac 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt @@ -26,7 +26,7 @@ interface ChattingRepository { enable: Boolean, ): Result -// suspend fun deleteChattingRoom(chatRoomId: Long): Result + suspend fun deleteChattingRoom(roomId: Long): Result suspend fun deleteChattingCrewKickOut( chatRoomId: Long, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt index 458acb3a..dcc329a1 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt @@ -1,6 +1,5 @@ package com.catchmate.domain.usecase.chatting -import com.catchmate.domain.model.chatting.DeleteChattingRoomResponse import com.catchmate.domain.repository.ChattingRepository import javax.inject.Inject @@ -9,6 +8,6 @@ class LeaveChattingRoomUseCase constructor( private val chattingRepository: ChattingRepository, ) { -// suspend operator fun invoke(chatRoomId: Long): Result = -// chattingRepository.deleteChattingRoom(chatRoomId) + suspend operator fun invoke(roomId: Long): Result = + chattingRepository.deleteChattingRoom(roomId) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt index ba728fc3..8e06ddde 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingHomeFragment.kt @@ -35,7 +35,6 @@ class ChattingHomeFragment : private var currentPage: Int = 0 private var hasNext = true private var isLoading = false - private var isFirstLoad = true private var deletedItemPos: Int = -1 private lateinit var chattingRoomListAdapter: ChattingRoomListAdapter @@ -132,13 +131,10 @@ class ChattingHomeFragment : } } } -// chattingHomeViewModel.leaveChattingRoomResponse.observe(viewLifecycleOwner) { response -> -// if (response.state) { -// chattingRoomListAdapter.removeItem(deletedItemPos) -// } else { -// Snackbar.make(requireView(), R.string.chatting_leave_room_fail, Snackbar.LENGTH_SHORT).show() -// } -// } + chattingHomeViewModel.leaveChattingRoomResponse.observe(viewLifecycleOwner) { response -> + Log.i("채팅방 나가기 성공", "$response") + chattingRoomListAdapter.removeItem(deletedItemPos) + } } private fun initRecyclerView() { @@ -221,7 +217,7 @@ class ChattingHomeFragment : swipedItemId: Long, ) { deletedItemPos = position -// chattingHomeViewModel.leaveChattingRoom(swipedItemId) + chattingHomeViewModel.leaveChattingRoom(swipedItemId) } override fun onListItemAllRemoved() { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt index b7cc0be5..9c72a9a4 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt @@ -40,9 +40,9 @@ class ChattingHomeViewModel val getChattingRoomListResponse: LiveData get() = _getChattingRoomListResponse -// private val _leaveChattingRoomResponse = MutableLiveData() -// val leaveChattingRoomResponse: LiveData -// get() = _leaveChattingRoomResponse + private val _leaveChattingRoomResponse = MutableLiveData() + val leaveChattingRoomResponse: LiveData + get() = _leaveChattingRoomResponse private val _errorMessage = MutableLiveData() val errorMessage: LiveData @@ -157,20 +157,20 @@ class ChattingHomeViewModel } } -// fun leaveChattingRoom(chatRoomId: Long) { -// viewModelScope.launch { -// val result = leaveChattingRoomUseCase(chatRoomId) -// result -// .onSuccess { response -> -// _leaveChattingRoomResponse.value = response -// }.onFailure { exception -> -// if (exception is ReissueFailureException) { -// _navigateToLogin.value = true -// } else { -// Log.d("ChattingHomeVM", exception.message.toString()) -// _errorMessage.value = "LeaveChattingRoomError" -// } -// } -// } -// } + fun leaveChattingRoom(roomId: Long) { + viewModelScope.launch { + val result = leaveChattingRoomUseCase(roomId) + result + .onSuccess { response -> + _leaveChattingRoomResponse.value = response + }.onFailure { exception -> + if (exception is ReissueFailureException) { + _navigateToLogin.value = true + } else { + Log.d("ChattingHomeVM", exception.message.toString()) + _errorMessage.value = "LeaveChattingRoomError" + } + } + } + } } From ea2bd50bc76030dfd43ebc668730c93ddb769cb3 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 18:49:51 +0900 Subject: [PATCH 06/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=EC=9E=90=20=EA=B0=95=ED=87=B4=20api=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/remote/ChattingService.kt | 11 +++++------ .../chatting/DeleteChattingCrewKickOutResponseDTO.kt | 5 ----- .../java/com/catchmate/data/mapper/ChattingMapper.kt | 7 ------- .../data/repository/ChattingRepositoryImpl.kt | 11 +++++------ .../chatting/DeleteChattingCrewKickOutResponse.kt | 5 ----- .../catchmate/domain/repository/ChattingRepository.kt | 7 +++---- .../usecase/chatting/KickOutChattingCrewUseCase.kt | 5 ++--- .../view/chatting/ChattingRoomFragment.kt | 3 +-- .../view/chatting/ChattingSettingFragment.kt | 10 ++++------ .../viewmodel/ChattingSettingViewModel.kt | 5 ++--- 10 files changed, 22 insertions(+), 47 deletions(-) delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingCrewKickOutResponseDTO.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingCrewKickOutResponse.kt diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt index 14143cbb..a1cd84c0 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt @@ -1,6 +1,5 @@ package com.catchmate.data.datasource.remote -import com.catchmate.data.dto.chatting.DeleteChattingCrewKickOutResponseDTO import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO @@ -47,11 +46,11 @@ interface ChattingService { @Path("roomId") roomId: Long, ): Response - @DELETE("chat-rooms/{chatRoomId}/users/{userId}") - suspend fun deleteChattingCrewKickOut( - @Path("chatRoomId") chatRoomId: Long, - @Path("userId") userId: Long, - ): Response + @DELETE("api/chat/rooms/{roomId}/members/{targetUserId}") + suspend fun deleteChattingCrew( + @Path("roomId") roomId: Long, + @Path("targetUserId") targetUserId: Long, + ): Response @GET("api/chat/rooms/{roomId}/messages") suspend fun getChattingMessages( diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingCrewKickOutResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingCrewKickOutResponseDTO.kt deleted file mode 100644 index 51b65f59..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/DeleteChattingCrewKickOutResponseDTO.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class DeleteChattingCrewKickOutResponseDTO( - val state: Boolean, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index 3ada7861..9a0e7bf5 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -1,7 +1,6 @@ package com.catchmate.data.mapper import com.catchmate.data.dto.chatting.ChatRoomInfoDTO -import com.catchmate.data.dto.chatting.DeleteChattingCrewKickOutResponseDTO import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO @@ -10,7 +9,6 @@ import com.catchmate.data.dto.chatting.PatchChattingRoomImageResponseDTO import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO import com.catchmate.data.mapper.BoardMapper.toBoard import com.catchmate.domain.model.chatting.ChatRoomInfo -import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse @@ -72,11 +70,6 @@ object ChattingMapper { joinedAt = dto.joinedAt, ) - fun toDeleteChattingCrewKickOutResponse(dto: DeleteChattingCrewKickOutResponseDTO): DeleteChattingCrewKickOutResponse = - DeleteChattingCrewKickOutResponse( - state = dto.state, - ) - fun toPatchChattingRoomImageResponse(dto: PatchChattingRoomImageResponseDTO): PatchChattingRoomImageResponse = PatchChattingRoomImageResponse( state = dto.state, diff --git a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt index 09f736dc..7ac9cb76 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt @@ -4,7 +4,6 @@ import com.catchmate.data.datasource.remote.ChattingService import com.catchmate.data.datasource.remote.RetrofitClient import com.catchmate.data.mapper.ChattingMapper import com.catchmate.data.util.ApiResponseHandleUtil.apiCall -import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse @@ -70,14 +69,14 @@ class ChattingRepositoryImpl transform = { it }, ) - override suspend fun deleteChattingCrewKickOut( + override suspend fun deleteChattingCrew( chatRoomId: Long, - userId: Long, - ): Result = + targetUserId: Long, + ): Result = apiCall( tag = this.tag, - apiFunction = { chattingApi.deleteChattingCrewKickOut(chatRoomId, userId) }, - transform = { ChattingMapper.toDeleteChattingCrewKickOutResponse(it!!) }, + apiFunction = { chattingApi.deleteChattingCrew(chatRoomId, targetUserId) }, + transform = { it }, ) override suspend fun getChattingMessages( diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingCrewKickOutResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingCrewKickOutResponse.kt deleted file mode 100644 index 8cd36be2..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/DeleteChattingCrewKickOutResponse.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class DeleteChattingCrewKickOutResponse( - val state: Boolean, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt index 5cfffeac..f32d3906 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt @@ -1,6 +1,5 @@ package com.catchmate.domain.repository -import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse @@ -28,10 +27,10 @@ interface ChattingRepository { suspend fun deleteChattingRoom(roomId: Long): Result - suspend fun deleteChattingCrewKickOut( + suspend fun deleteChattingCrew( chatRoomId: Long, - userId: Long, - ): Result + targetUserId: Long, + ): Result suspend fun getChattingMessages( chatRoomId: Long, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/KickOutChattingCrewUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/KickOutChattingCrewUseCase.kt index c293a58c..e9dbd0e1 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/KickOutChattingCrewUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/KickOutChattingCrewUseCase.kt @@ -1,6 +1,5 @@ package com.catchmate.domain.usecase.chatting -import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.repository.ChattingRepository import javax.inject.Inject @@ -11,6 +10,6 @@ class KickOutChattingCrewUseCase ) { suspend operator fun invoke( chatRoomId: Long, - userId: Long, - ): Result = chattingRepository.deleteChattingCrewKickOut(chatRoomId, userId) + targetUserId: Long, + ): Result = chattingRepository.deleteChattingCrew(chatRoomId, targetUserId) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt index 89426835..99e36eeb 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt @@ -48,9 +48,8 @@ class ChattingRoomFragment : BaseFragment(FragmentC private var isLoading = false private var isApiCalled = false private var isFirstLoad = true - private val isPendingIntent by lazy { arguments?.getBoolean("isPendingIntent") ?: false } + private val isPendingIntent by lazy { arguments?.getBoolean("isPendingIntent") == true } private var isNotificationEnabled = false - private lateinit var chatRoomInfo: ChatRoomInfo private lateinit var chatListAdapter: ChatListAdapter override fun onViewCreated( diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt index 81fdc4d5..7ab04fa1 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt @@ -94,12 +94,10 @@ class ChattingSettingFragment : private fun initViewModel() { chattingSettingViewModel.kickOutChattingCrewResponse.observe(viewLifecycleOwner) { response -> - if (response.state) { - Log.i("강퇴 성공", "✅ $deletedCrewId \n $chattingCrewList") - chattingCrewList = chattingCrewList.filter { it.userId != deletedCrewId }.toMutableList() - Log.i("crew list", "$chattingCrewList") - chattingCrewAdapter.submitList(chattingCrewList) - } + Log.i("강퇴 성공", "✅ $deletedCrewId \n $chattingCrewList") + chattingCrewList = chattingCrewList.filter { it.userId != deletedCrewId }.toMutableList() + Log.i("crew list", "$chattingCrewList") + chattingCrewAdapter.submitList(chattingCrewList) } chattingSettingViewModel.patchChattingRoomImageResponse.observe(viewLifecycleOwner) { response -> if (response.state) { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt index 47be0931..6f3cc208 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt @@ -5,7 +5,6 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.catchmate.domain.exception.ReissueFailureException -import com.catchmate.domain.model.chatting.DeleteChattingCrewKickOutResponse import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.usecase.chatting.KickOutChattingCrewUseCase import com.catchmate.domain.usecase.chatting.PatchChattingRoomImageUseCase @@ -21,8 +20,8 @@ class ChattingSettingViewModel private val kickOutChattingCrewUseCase: KickOutChattingCrewUseCase, private val patchChattingRoomImageUseCase: PatchChattingRoomImageUseCase, ) : ViewModel() { - private val _kickOutChattingCrewResponse = MutableLiveData() - val kickOutChattingCrewResponse: LiveData + private val _kickOutChattingCrewResponse = MutableLiveData() + val kickOutChattingCrewResponse: LiveData get() = _kickOutChattingCrewResponse private val _patchChattingRoomImageResponse = MutableLiveData() From 1c47d28197271b706faeb4271af7cdcb327ab80c Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 21:08:49 +0900 Subject: [PATCH 07/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B3=80=EA=B2=BD=20api=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchmate/data/datasource/remote/ChattingService.kt | 7 +++---- .../dto/chatting/PatchChattingRoomImageResponseDTO.kt | 5 ----- .../java/com/catchmate/data/mapper/ChattingMapper.kt | 7 ------- .../catchmate/data/repository/ChattingRepositoryImpl.kt | 9 ++++----- .../model/chatting/PatchChattingRoomImageResponse.kt | 5 ----- .../catchmate/domain/repository/ChattingRepository.kt | 5 ++--- .../usecase/chatting/PatchChattingRoomImageUseCase.kt | 5 ++--- .../view/chatting/ChattingSettingFragment.kt | 6 ++---- .../presentation/viewmodel/ChattingSettingViewModel.kt | 9 ++++----- 9 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PatchChattingRoomImageResponseDTO.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PatchChattingRoomImageResponse.kt diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt index a1cd84c0..6d93611d 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt @@ -3,7 +3,6 @@ package com.catchmate.data.datasource.remote import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO -import com.catchmate.data.dto.chatting.PatchChattingRoomImageResponseDTO import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO import okhttp3.MultipartBody import retrofit2.Response @@ -29,11 +28,11 @@ interface ChattingService { ): Response?> @Multipart - @PATCH("chat-rooms/{chatRoomId}/image") + @PATCH("api/chat/rooms/{roomId}/image") suspend fun patchChattingRoomImage( - @Path("chatRoomId") chatRoomId: Long, + @Path("roomId") roomId: Long, @Part chatRoomImage: MultipartBody.Part, - ): Response + ): Response @PUT("chat-rooms/{chatRoomId}/notification") suspend fun putChattingRoomAlarm( diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PatchChattingRoomImageResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PatchChattingRoomImageResponseDTO.kt deleted file mode 100644 index 1fbd96e0..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PatchChattingRoomImageResponseDTO.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class PatchChattingRoomImageResponseDTO( - val state: Boolean, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index 9a0e7bf5..240d98a4 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -5,7 +5,6 @@ import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO import com.catchmate.data.dto.chatting.LastMessageInfoDto -import com.catchmate.data.dto.chatting.PatchChattingRoomImageResponseDTO import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO import com.catchmate.data.mapper.BoardMapper.toBoard import com.catchmate.domain.model.chatting.ChatRoomInfo @@ -13,7 +12,6 @@ import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse import com.catchmate.domain.model.chatting.LastMessageInfo -import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse object ChattingMapper { @@ -70,11 +68,6 @@ object ChattingMapper { joinedAt = dto.joinedAt, ) - fun toPatchChattingRoomImageResponse(dto: PatchChattingRoomImageResponseDTO): PatchChattingRoomImageResponse = - PatchChattingRoomImageResponse( - state = dto.state, - ) - fun toPutChattingRoomAlarmResponse(dto: PutChattingRoomAlarmResponseDTO): PutChattingRoomAlarmResponse = PutChattingRoomAlarmResponse( state = dto.state, diff --git a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt index 7ac9cb76..83718e88 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt @@ -7,7 +7,6 @@ import com.catchmate.data.util.ApiResponseHandleUtil.apiCall import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse -import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse import com.catchmate.domain.repository.ChattingRepository import okhttp3.MultipartBody @@ -43,13 +42,13 @@ class ChattingRepositoryImpl ) override suspend fun patchChattingRoomImage( - chatRoomId: Long, + roomId: Long, chatRoomImage: MultipartBody.Part, - ): Result = + ): Result = apiCall( tag = this.tag, - apiFunction = { chattingApi.patchChattingRoomImage(chatRoomId, chatRoomImage) }, - transform = { ChattingMapper.toPatchChattingRoomImageResponse(it!!) }, + apiFunction = { chattingApi.patchChattingRoomImage(roomId, chatRoomImage) }, + transform = { it }, ) override suspend fun putChattingRoomAlarm( diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PatchChattingRoomImageResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PatchChattingRoomImageResponse.kt deleted file mode 100644 index ef20a7cf..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PatchChattingRoomImageResponse.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class PatchChattingRoomImageResponse( - val state: Boolean, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt index f32d3906..0cc4d1ea 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt @@ -3,7 +3,6 @@ package com.catchmate.domain.repository import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse -import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse import okhttp3.MultipartBody @@ -16,9 +15,9 @@ interface ChattingRepository { suspend fun getChattingCrewList(chatRoomId: Long): Result> suspend fun patchChattingRoomImage( - chatRoomId: Long, + roomId: Long, chatRoomImage: MultipartBody.Part, - ): Result + ): Result suspend fun putChattingRoomAlarm( chatRoomId: Long, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PatchChattingRoomImageUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PatchChattingRoomImageUseCase.kt index 03d5879d..242814d5 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PatchChattingRoomImageUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PatchChattingRoomImageUseCase.kt @@ -1,6 +1,5 @@ package com.catchmate.domain.usecase.chatting -import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.repository.ChattingRepository import okhttp3.MultipartBody import javax.inject.Inject @@ -11,7 +10,7 @@ class PatchChattingRoomImageUseCase private val chattingRepository: ChattingRepository, ) { suspend operator fun invoke( - chatRoomId: Long, + roomId: Long, chatRoomImage: MultipartBody.Part, - ): Result = chattingRepository.patchChattingRoomImage(chatRoomId, chatRoomImage) + ): Result = chattingRepository.patchChattingRoomImage(roomId, chatRoomImage) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt index 7ab04fa1..90eb5aa3 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt @@ -100,10 +100,8 @@ class ChattingSettingFragment : chattingCrewAdapter.submitList(chattingCrewList) } chattingSettingViewModel.patchChattingRoomImageResponse.observe(viewLifecycleOwner) { response -> - if (response.state) { - Log.d("📸채팅방 프로필 변경 성공", "성공") - binding.ivChattingSettingThumbnail.setImageBitmap(updatedBitmap) - } + Log.d("📸채팅방 프로필 변경 성공", "성공") + binding.ivChattingSettingThumbnail.setImageBitmap(updatedBitmap) } chattingSettingViewModel.navigateToLogin.observe(viewLifecycleOwner) { isTrue -> if (isTrue) { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt index 6f3cc208..f155905c 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingSettingViewModel.kt @@ -5,7 +5,6 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.catchmate.domain.exception.ReissueFailureException -import com.catchmate.domain.model.chatting.PatchChattingRoomImageResponse import com.catchmate.domain.usecase.chatting.KickOutChattingCrewUseCase import com.catchmate.domain.usecase.chatting.PatchChattingRoomImageUseCase import dagger.hilt.android.lifecycle.HiltViewModel @@ -24,8 +23,8 @@ class ChattingSettingViewModel val kickOutChattingCrewResponse: LiveData get() = _kickOutChattingCrewResponse - private val _patchChattingRoomImageResponse = MutableLiveData() - val patchChattingRoomImageResponse: LiveData + private val _patchChattingRoomImageResponse = MutableLiveData() + val patchChattingRoomImageResponse: LiveData get() = _patchChattingRoomImageResponse private val _errorMessage = MutableLiveData() @@ -56,11 +55,11 @@ class ChattingSettingViewModel } fun patchChattingRoomImage( - chatRoomId: Long, + roomId: Long, chatRoomImage: MultipartBody.Part, ) { viewModelScope.launch { - val result = patchChattingRoomImageUseCase(chatRoomId, chatRoomImage) + val result = patchChattingRoomImageUseCase(roomId, chatRoomImage) result .onSuccess { response -> _patchChattingRoomImageResponse.value = response From 28d30386bf13ce103ab9be890002eead9c49a9d7 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 21:54:04 +0900 Subject: [PATCH 08/14] =?UTF-8?q?fix:=20=EC=B1=84=ED=8C=85=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=97=90=EC=84=9C=20=EB=A7=88=EC=A7=80=EB=A7=89=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=8B=9C=EA=B0=84=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/catchmate/presentation/util/DateUtils.kt | 3 ++- .../presentation/view/chatting/ChattingRoomListAdapter.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt index b442a687..0b343424 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/util/DateUtils.kt @@ -115,7 +115,8 @@ object DateUtils { val parsedTime = LocalDateTime .parse(dateTime, formatter) - .atZone(ZoneId.of("Asia/Seoul")) + .atZone(ZoneId.of("UTC")) + .withZoneSameInstant(ZoneId.of("Asia/Seoul")) .toInstant() val now = Instant.now() val duration = Duration.between(parsedTime, now) diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt index 8bfbee05..bb02a566 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt @@ -95,17 +95,18 @@ class ChattingRoomListAdapter( ) tvChattingItemTitle.text = chatRoomInfo.board.title - tvChattingItemTime.text = formatLastChatTime(chatRoomInfo.createdAt) if (chatRoomInfo.lastMessage == null) { tvChattingItemNew.visibility = View.VISIBLE tvChattingItemPeopleCount.visibility = View.GONE tvChattingItemLastChat.text = root.context.getString(R.string.chatting_start_message) tvChattingItemUnreadMessageCount.visibility = View.GONE + tvChattingItemTime.text = formatLastChatTime(chatRoomInfo.createdAt) } else { tvChattingItemNew.visibility = View.GONE tvChattingItemPeopleCount.visibility = View.VISIBLE tvChattingItemPeopleCount.text = chatRoomInfo.board.currentPerson.toString() tvChattingItemLastChat.text = chatRoomInfo.lastMessage?.content + tvChattingItemTime.text = formatLastChatTime(chatRoomInfo.lastMessage?.createdAt!!) if (chatRoomInfo.unreadCount == 0L) { tvChattingItemUnreadMessageCount.visibility = View.GONE } else { From d8406793f8fc35ee0e950d31608ebdff2bff61f3 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 21:55:24 +0900 Subject: [PATCH 09/14] =?UTF-8?q?fix:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EB=82=B4=20SYSTEM=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=98?= =?UTF-8?q?=EC=8B=A0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/chatting/ChatListAdapter.kt | 4 +- .../viewmodel/ChattingRoomViewModel.kt | 66 +++++-------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt index 01fa45c5..bc520b08 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt @@ -1,5 +1,6 @@ package com.catchmate.presentation.view.chatting +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -76,7 +77,6 @@ class ChatListAdapter( ) : RecyclerView.ViewHolder(binding.root) { fun bind( chat: GetChattingMessagesResponse, - viewType: Int, ) { binding.tvChattingParticipantAlert.text = chat.content } @@ -136,7 +136,7 @@ class ChatListAdapter( MY_CHAT -> (holder as SendChatViewHolder).bind(currentList[position]) OTHER_CHAT -> (holder as ReceivedChatViewHolder).bind(currentList[position]) DATE -> (holder as ChattingDateViewHolder).bind(currentList[position]) - SYSTEM -> (holder as ChattingParticipantViewHolder).bind(currentList[position], getItemViewType(position)) + SYSTEM -> (holder as ChattingParticipantViewHolder).bind(currentList[position]) } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt index cf894423..20282194 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt @@ -151,55 +151,25 @@ class ChattingRoomViewModel stompClient?.topic("/sub/chat/room/$chatRoomId")?.subscribe({ message -> Log.i("✅ Msg", message.payload) val jsonObject = JSONObject(message.payload) + val messageId = jsonObject.getLong("messageId") + val roomId = jsonObject.getLong("roomId") + val senderId = jsonObject.getLong("senderId") + val senderNickname = jsonObject.getString("senderNickname") + val senderProfileImage = jsonObject.getString("senderProfileImage") + val content = jsonObject.getString("content") val messageType = jsonObject.getString("messageType") - val chatMessage: GetChattingMessagesResponse = - when (messageType) { -// ChatMessageType.DATE.name -> { -// val roomId = jsonObject.getString("chatRoomId").toLong() -// val content = jsonObject.getString("content") -// val senderId = jsonObject.getString("senderId").toLong() -// ChatMessageInfo( -// chatMessageId = "", -// roomId = roomId, -// content = content, -// senderId = senderId, -// messageType = messageType, -// ) -// } - - ChatMessageType.TEXT.name -> { - val messageId = jsonObject.getLong("messageId") - val roomId = jsonObject.getLong("roomId") - val senderId = jsonObject.getLong("senderId") - val senderNickname = jsonObject.getString("senderNickname") - val senderProfileImage = jsonObject.getString("senderProfileImage") - val content = jsonObject.getString("content") - val createdAt = jsonObject.getString("createdAt") - GetChattingMessagesResponse( - messageId = messageId, - chatRoomId = roomId, - senderId = senderId, - senderNickName = senderNickname, - senderProfileImageUrl = senderProfileImage, - content = content, - messageType = messageType, - createdAt = createdAt, - ) - } - - else -> { // 채팅방 나가고 들어올때 메시지 처리하기 - GetChattingMessagesResponse( - messageId = -1, - chatRoomId = -1, - senderId = -1, - senderNickName = "", - senderProfileImageUrl = "", - content = "", - messageType = "", - createdAt = "", - ) - } - } + val createdAt = jsonObject.getString("createdAt") + val chatMessage = + GetChattingMessagesResponse( + messageId = messageId, + chatRoomId = roomId, + senderId = senderId, + senderNickName = senderNickname, + senderProfileImageUrl = senderProfileImage, + content = content, + messageType = messageType, + createdAt = createdAt, + ) addChatMessage(chatMessage) sendIsMsgRead(chatRoomId) }, { error -> From 2847b60bd0a7ab3c6d2fece9322c10531cc96b1a Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 22:32:43 +0900 Subject: [PATCH 10/14] =?UTF-8?q?fix:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=ED=99=94=EB=A9=B4=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=B1=84=ED=8C=85=EB=B3=B4=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AD=20=EC=8B=9C=20chatRoomId=20-1=EB=A1=9C=20?= =?UTF-8?q?=EB=84=98=EA=B2=A8=EC=A7=80=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/board/GetBoardResponseDTO.kt | 2 +- .../domain/model/board/GetBoardResponse.kt | 2 +- .../domain/model/chatting/ChatRoomInfo.kt | 1 - .../view/post/ReadPostFragment.kt | 23 ++++++++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/board/GetBoardResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/board/GetBoardResponseDTO.kt index 7475889a..e7615a33 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/board/GetBoardResponseDTO.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/dto/board/GetBoardResponseDTO.kt @@ -15,7 +15,7 @@ data class GetBoardResponseDTO( val liftUpDate: String, val bookMarked: Boolean, val buttonStatus: String, - val myEnrollId: Long, + val myEnrollId: Long?, val chatRoomId: Long, val cheerClub: ClubDTO, val game: GameInfoDTO, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/board/GetBoardResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/board/GetBoardResponse.kt index dd88ac28..2066e874 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/board/GetBoardResponse.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/board/GetBoardResponse.kt @@ -18,7 +18,7 @@ data class GetBoardResponse( val liftUpDate: String, val bookMarked: Boolean, val buttonStatus: String, - val myEnrollId: Long, + val myEnrollId: Long?, val chatRoomId: Long, val cheerClub: Club, val game: GameInfo, diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt index 7e738656..5c1a2285 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt @@ -1,6 +1,5 @@ package com.catchmate.domain.model.chatting -import android.os.Parcel import android.os.Parcelable import com.catchmate.domain.model.board.Board import kotlinx.parcelize.Parcelize diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt index db1379ae..ef3a0050 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt @@ -17,8 +17,10 @@ import androidx.fragment.app.viewModels import androidx.navigation.NavOptions import androidx.navigation.fragment.findNavController import com.bumptech.glide.Glide +import com.catchmate.domain.model.board.Board import com.catchmate.domain.model.board.BoardMode import com.catchmate.domain.model.board.GetBoardResponse +import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.enroll.PostEnrollRequest import com.catchmate.domain.model.enumclass.EnrollState import com.catchmate.domain.model.user.GetUserProfileResponse @@ -219,8 +221,27 @@ class ReadPostFragment : BaseFragment(FragmentReadPostB } EnrollState.VIEW_CHAT -> { + val chatRoomInfo = + ChatRoomInfo( + chatRoomId = readPostViewModel.getBoardResponse.value?.chatRoomId!!, + board = + Board( + boardId = readPostViewModel.getBoardResponse.value?.boardId!!, + title = readPostViewModel.getBoardResponse.value?.title!!, + content = readPostViewModel.getBoardResponse.value?.content!!, + currentPerson = readPostViewModel.getBoardResponse.value?.currentPerson!!, + maxPerson = readPostViewModel.getBoardResponse.value?.maxPerson!!, + bookMarked = readPostViewModel.getBoardResponse.value?.bookMarked!!, + cheerClub = readPostViewModel.getBoardResponse.value?.cheerClub!!, + gameResponse =readPostViewModel.getBoardResponse.value?.game!!, + userResponse = readPostViewModel.getBoardResponse.value?.user!!, + ), + lastMessage = null, + unreadCount = 0, + createdAt = "", + ) val bundle = Bundle() - bundle.putLong("chatRoomId", readPostViewModel.getBoardResponse.value?.chatRoomId!!) + bundle.putParcelable("chatRoomInfo", chatRoomInfo) findNavController().navigate(R.id.action_readPostFragment_to_chattingRoomFragment, bundle) } From cf51e400e8067f191a0e540e913a8426fe66202d Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 23:15:57 +0900 Subject: [PATCH 11/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EB=B6=88=EB=9F=AC=EC=98=AC=20=EB=95=8C?= =?UTF-8?q?=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EC=99=80=20=EC=95=8C=EB=A6=BC=20=EC=88=98=EC=8B=A0=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dto/chatting/ChatRoomInfoDTO.kt | 2 + .../catchmate/data/mapper/ChattingMapper.kt | 2 + .../domain/model/chatting/ChatRoomInfo.kt | 2 + .../view/chatting/ChattingRoomListAdapter.kt | 69 +++++++------------ .../view/post/ReadPostFragment.kt | 2 + .../viewmodel/ChattingHomeViewModel.kt | 5 -- 6 files changed, 33 insertions(+), 49 deletions(-) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt index abcec69d..f9bc0514 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/ChatRoomInfoDTO.kt @@ -7,5 +7,7 @@ data class ChatRoomInfoDTO( val board: BoardDTO, val lastMessage: LastMessageInfoDto?, val unreadCount: Long, + val chatRoomImageUrl: String?, val createdAt: String, + val notificationOn: Boolean, ) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index 240d98a4..cd98ef69 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -30,7 +30,9 @@ object ChattingMapper { board = toBoard(dto.board), lastMessage = toLastMessageInfo(dto.lastMessage), unreadCount = dto.unreadCount, + chatRoomImageUrl = dto.chatRoomImageUrl, createdAt = dto.createdAt, + notificationOn = dto.notificationOn, ) private fun toLastMessageInfo(dto: LastMessageInfoDto?): LastMessageInfo? = diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt index 5c1a2285..adf43ccb 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/ChatRoomInfo.kt @@ -10,5 +10,7 @@ data class ChatRoomInfo( val board: Board, val lastMessage: LastMessageInfo?, val unreadCount: Long, + val chatRoomImageUrl: String?, val createdAt: String, + val notificationOn: Boolean, ) : Parcelable diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt index bb02a566..a50b5139 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomListAdapter.kt @@ -49,50 +49,31 @@ class ChattingRoomListAdapter( root.setOnClickListener { onChattingRoomSelectedListener.onChattingRoomSelected(chatRoomInfo) } - // 채팅방 이미지가 변경된 적 없는 경우 chatRoomImage에 cheerTeamId가 String으로 담겨옴 - // 해당 변수를 int로 변환할 때 예외 처리를 통해 변경된 적 있을 경우의 imageUrl을 imageView에 표시 -// try { -// val clubId = chatRoomInfo.chatRoomImage.toInt() -// val logoResource = convertTeamLogo(clubId) -// ivChattingItemLogo.visibility = View.VISIBLE -// Glide -// .with(root.context) -// .load(logoResource) -// .into(ivChattingItemLogo) -// DrawableCompat -// .setTint( -// ivChattingItemBg.drawable, -// convertTeamColor( -// root.context, -// clubId, -// true, -// "chattingHome", -// ), -// ) -// } catch (e: Exception) { -// ivChattingItemLogo.visibility = View.GONE -// Glide -// .with(root.context) -// .load(chatRoomInfo.chatRoomImage) -// .into(ivChattingItemBg) -// } - val clubId = chatRoomInfo.board.cheerClub.clubId - val logoResource = convertTeamLogo(clubId) - ivChattingItemLogo.visibility = View.VISIBLE - Glide - .with(root.context) - .load(logoResource) - .into(ivChattingItemLogo) - DrawableCompat - .setTint( - ivChattingItemBg.drawable, - convertTeamColor( - root.context, - clubId, - true, - "chattingHome", - ), - ) + if (chatRoomInfo.chatRoomImageUrl == null) { + val clubId = chatRoomInfo.board.cheerClub.clubId + val logoResource = convertTeamLogo(clubId) + ivChattingItemLogo.visibility = View.VISIBLE + Glide + .with(root.context) + .load(logoResource) + .into(ivChattingItemLogo) + DrawableCompat + .setTint( + ivChattingItemBg.drawable, + convertTeamColor( + root.context, + clubId, + true, + "chattingHome", + ), + ) + } else { + ivChattingItemLogo.visibility = View.GONE + Glide + .with(root.context) + .load(chatRoomInfo.chatRoomImageUrl) + .into(ivChattingItemBg) + } tvChattingItemTitle.text = chatRoomInfo.board.title if (chatRoomInfo.lastMessage == null) { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt index ef3a0050..7dc5676c 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt @@ -238,7 +238,9 @@ class ReadPostFragment : BaseFragment(FragmentReadPostB ), lastMessage = null, unreadCount = 0, + chatRoomImageUrl = null, createdAt = "", + notificationOn = true, ) val bundle = Bundle() bundle.putParcelable("chatRoomInfo", chatRoomInfo) diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt index 9c72a9a4..190279de 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingHomeViewModel.kt @@ -1,25 +1,20 @@ package com.catchmate.presentation.viewmodel import android.util.Log -import androidx.core.content.ContextCompat -import androidx.core.content.ContextCompat.getString import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.catchmate.domain.exception.ReissueFailureException import com.catchmate.domain.model.chatting.GetChattingRoomListResponse -import com.catchmate.domain.model.chatting.LastMessageInfo import com.catchmate.domain.usecase.chatting.GetChattingRoomListUseCase import com.catchmate.domain.usecase.chatting.LeaveChattingRoomUseCase import com.catchmate.presentation.BuildConfig -import com.catchmate.presentation.R import dagger.hilt.android.lifecycle.HiltViewModel import io.reactivex.disposables.Disposable import kotlinx.coroutines.launch import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor -import org.json.JSONObject import ua.naiksoftware.stomp.Stomp import ua.naiksoftware.stomp.StompClient import ua.naiksoftware.stomp.dto.LifecycleEvent From bbe5597d561bd3bc09aa152b92d38c980a3a83e2 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 24 Feb 2026 23:34:10 +0900 Subject: [PATCH 12/14] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20api=20=EC=88=98=EC=A0=95=EC=82=AC=ED=95=AD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/remote/ChattingService.kt | 11 ++--- .../PutChattingRoomAlarmRequestDTO.kt | 5 +++ .../PutChattingRoomAlarmResponseDTO.kt | 5 --- .../catchmate/data/mapper/ChattingMapper.kt | 10 ++--- .../data/repository/ChattingRepositoryImpl.kt | 17 ++++--- .../chatting/PutChattingRoomAlarmRequest.kt | 5 +++ .../chatting/PutChattingRoomAlarmResponse.kt | 5 --- .../domain/repository/ChattingRepository.kt | 8 ++-- .../chatting/PutChattingRoomAlarmUseCase.kt | 8 ++-- .../view/chatting/ChattingRoomFragment.kt | 13 ++++-- .../viewmodel/ChattingRoomViewModel.kt | 45 +++++++++---------- 11 files changed, 71 insertions(+), 61 deletions(-) create mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmRequestDTO.kt delete mode 100644 CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmResponseDTO.kt create mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmRequest.kt delete mode 100644 CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmResponse.kt diff --git a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt index 6d93611d..8009a98d 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/datasource/remote/ChattingService.kt @@ -3,9 +3,10 @@ package com.catchmate.data.datasource.remote import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO -import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO +import com.catchmate.data.dto.chatting.PutChattingRoomAlarmRequestDTO import okhttp3.MultipartBody import retrofit2.Response +import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.Multipart @@ -34,11 +35,11 @@ interface ChattingService { @Part chatRoomImage: MultipartBody.Part, ): Response - @PUT("chat-rooms/{chatRoomId}/notification") + @PUT("api/chat/rooms/{roomId}/notifications") suspend fun putChattingRoomAlarm( - @Path("chatRoomId") chatRoomId: Long, - @Query("enable") enable: Boolean, - ): Response + @Path("roomId") roomId: Long, + @Body putChattingRoomAlarmRequestDTO: PutChattingRoomAlarmRequestDTO, + ): Response @DELETE("api/chat/rooms/{roomId}") suspend fun deleteChattingRoom( diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmRequestDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmRequestDTO.kt new file mode 100644 index 00000000..adc9b0d8 --- /dev/null +++ b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmRequestDTO.kt @@ -0,0 +1,5 @@ +package com.catchmate.data.dto.chatting + +data class PutChattingRoomAlarmRequestDTO( + val on: Boolean, +) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmResponseDTO.kt b/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmResponseDTO.kt deleted file mode 100644 index e778cbad..00000000 --- a/CatchMate/data/src/main/java/com/catchmate/data/dto/chatting/PutChattingRoomAlarmResponseDTO.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.data.dto.chatting - -data class PutChattingRoomAlarmResponseDTO( - val state: Boolean, -) diff --git a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt index cd98ef69..c9e5adeb 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/mapper/ChattingMapper.kt @@ -5,14 +5,14 @@ import com.catchmate.data.dto.chatting.GetChattingCrewListResponseDTO import com.catchmate.data.dto.chatting.GetChattingMessagesResponseDTO import com.catchmate.data.dto.chatting.GetChattingRoomListResponseDTO import com.catchmate.data.dto.chatting.LastMessageInfoDto -import com.catchmate.data.dto.chatting.PutChattingRoomAlarmResponseDTO +import com.catchmate.data.dto.chatting.PutChattingRoomAlarmRequestDTO import com.catchmate.data.mapper.BoardMapper.toBoard import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse import com.catchmate.domain.model.chatting.LastMessageInfo -import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse +import com.catchmate.domain.model.chatting.PutChattingRoomAlarmRequest object ChattingMapper { fun toGetChattingRoomListResponse(dto: GetChattingRoomListResponseDTO): GetChattingRoomListResponse = @@ -70,8 +70,8 @@ object ChattingMapper { joinedAt = dto.joinedAt, ) - fun toPutChattingRoomAlarmResponse(dto: PutChattingRoomAlarmResponseDTO): PutChattingRoomAlarmResponse = - PutChattingRoomAlarmResponse( - state = dto.state, + fun toPutChattingRoomAlarmRequestDTO(request: PutChattingRoomAlarmRequest): PutChattingRoomAlarmRequestDTO = + PutChattingRoomAlarmRequestDTO( + on = request.on, ) } diff --git a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt index 83718e88..bd4877c3 100644 --- a/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt +++ b/CatchMate/data/src/main/java/com/catchmate/data/repository/ChattingRepositoryImpl.kt @@ -7,7 +7,7 @@ import com.catchmate.data.util.ApiResponseHandleUtil.apiCall import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse -import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse +import com.catchmate.domain.model.chatting.PutChattingRoomAlarmRequest import com.catchmate.domain.repository.ChattingRepository import okhttp3.MultipartBody import javax.inject.Inject @@ -52,13 +52,18 @@ class ChattingRepositoryImpl ) override suspend fun putChattingRoomAlarm( - chatRoomId: Long, - enable: Boolean, - ): Result = + roomId: Long, + request: PutChattingRoomAlarmRequest, + ): Result = apiCall( tag = this.tag, - apiFunction = { chattingApi.putChattingRoomAlarm(chatRoomId, enable) }, - transform = { ChattingMapper.toPutChattingRoomAlarmResponse(it!!) }, + apiFunction = { + chattingApi.putChattingRoomAlarm( + roomId, + ChattingMapper.toPutChattingRoomAlarmRequestDTO(request), + ) + }, + transform = { it }, ) override suspend fun deleteChattingRoom(roomId: Long): Result = diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmRequest.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmRequest.kt new file mode 100644 index 00000000..b5c853d1 --- /dev/null +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmRequest.kt @@ -0,0 +1,5 @@ +package com.catchmate.domain.model.chatting + +data class PutChattingRoomAlarmRequest( + val on: Boolean, +) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmResponse.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmResponse.kt deleted file mode 100644 index 20a61bcf..00000000 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/model/chatting/PutChattingRoomAlarmResponse.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.catchmate.domain.model.chatting - -data class PutChattingRoomAlarmResponse( - val state: Boolean, -) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt index 0cc4d1ea..fff585be 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/repository/ChattingRepository.kt @@ -3,7 +3,7 @@ package com.catchmate.domain.repository import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse import com.catchmate.domain.model.chatting.GetChattingRoomListResponse -import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse +import com.catchmate.domain.model.chatting.PutChattingRoomAlarmRequest import okhttp3.MultipartBody interface ChattingRepository { @@ -20,9 +20,9 @@ interface ChattingRepository { ): Result suspend fun putChattingRoomAlarm( - chatRoomId: Long, - enable: Boolean, - ): Result + roomId: Long, + dto: PutChattingRoomAlarmRequest, + ): Result suspend fun deleteChattingRoom(roomId: Long): Result diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PutChattingRoomAlarmUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PutChattingRoomAlarmUseCase.kt index 48589e2d..c2f7d6e2 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PutChattingRoomAlarmUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/PutChattingRoomAlarmUseCase.kt @@ -1,6 +1,6 @@ package com.catchmate.domain.usecase.chatting -import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse +import com.catchmate.domain.model.chatting.PutChattingRoomAlarmRequest import com.catchmate.domain.repository.ChattingRepository import javax.inject.Inject @@ -10,7 +10,7 @@ class PutChattingRoomAlarmUseCase private val chattingRepository: ChattingRepository, ) { suspend operator fun invoke( - chatRoomId: Long, - enable: Boolean, - ): Result = chattingRepository.putChattingRoomAlarm(chatRoomId, enable) + roomId: Long, + request: PutChattingRoomAlarmRequest, + ): Result = chattingRepository.putChattingRoomAlarm(roomId, request) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt index 99e36eeb..aea83a19 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt @@ -21,6 +21,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.GetChattingCrewListResponse +import com.catchmate.domain.model.chatting.PutChattingRoomAlarmRequest import com.catchmate.domain.model.enumclass.ChatMessageType import com.catchmate.presentation.R import com.catchmate.presentation.databinding.FragmentChattingRoomBinding @@ -36,7 +37,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.sidesheet.SideSheetDialog import dagger.hilt.android.AndroidEntryPoint import org.json.JSONObject -import kotlin.lazy @AndroidEntryPoint class ChattingRoomFragment : BaseFragment(FragmentChattingRoomBinding::inflate) { @@ -114,7 +114,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC } chattingRoomViewModel.chattingRoomInfo.observe(viewLifecycleOwner) { info -> if (info != null) { -// isNotificationEnabled = info.isNotificationEnabled + isNotificationEnabled = info.notificationOn initChatRoomInfo(info) initHeader(info) } @@ -350,7 +350,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC // 채팅방 이미지 url, 참여자 목록, 로그인 유저 id, 게시글 작성자 id, 채팅방 id 넘김 val bundle = Bundle().apply { -// putString("chattingRoomImage", info.chatRoomImage) + putString("chattingRoomImage", info.chatRoomImageUrl) putParcelableArrayList("chattingCrewList", chattingRoomViewModel.getChattingCrewListResponse.value as ArrayList? ) @@ -368,7 +368,12 @@ class ChattingRoomFragment : BaseFragment(FragmentC toggleSideSheetChattingRoomNotification.setOnClickListener { isNotificationEnabled = !isNotificationEnabled toggleSideSheetChattingRoomNotification.isChecked = isNotificationEnabled -// chattingRoomViewModel.putChattingRoomAlarm(chatRoomId, isNotificationEnabled) + chattingRoomViewModel.putChattingRoomAlarm( + chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1, + PutChattingRoomAlarmRequest( + isNotificationEnabled, + ) + ) } layoutSideSheetPostInfo.setOnClickListener { val bundle = Bundle() diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt index 20282194..fe92a61c 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt @@ -9,8 +9,7 @@ import com.catchmate.domain.exception.ReissueFailureException import com.catchmate.domain.model.chatting.ChatRoomInfo import com.catchmate.domain.model.chatting.GetChattingCrewListResponse import com.catchmate.domain.model.chatting.GetChattingMessagesResponse -import com.catchmate.domain.model.chatting.PutChattingRoomAlarmResponse -import com.catchmate.domain.model.enumclass.ChatMessageType +import com.catchmate.domain.model.chatting.PutChattingRoomAlarmRequest import com.catchmate.domain.usecase.chatting.GetChattingCrewListUseCase import com.catchmate.domain.usecase.chatting.GetChattingMessagesUseCase import com.catchmate.domain.usecase.chatting.PutChattingRoomAlarmUseCase @@ -55,8 +54,8 @@ class ChattingRoomViewModel val isLeft: LiveData get() = _isLeft - private val _putChattingRoomAlarmResponse = MutableLiveData() - val putChattingRoomAlarmResponse: LiveData + private val _putChattingRoomAlarmResponse = MutableLiveData() + val putChattingRoomAlarmResponse: LiveData get() = _putChattingRoomAlarmResponse private val _errorMessage = MutableLiveData() @@ -288,23 +287,23 @@ class ChattingRoomViewModel } } } -// -// fun putChattingRoomAlarm( -// chatRoomId: Long, -// enable: Boolean, -// ) { -// viewModelScope.launch { -// val result = putChattingRoomAlarmUseCase(chatRoomId, enable) -// result -// .onSuccess { response -> -// _putChattingRoomAlarmResponse.value = response -// }.onFailure { exception -> -// if (exception is ReissueFailureException) { -// _navigateToLogin.value = true -// } else { -// _errorMessage.value = exception.message -// } -// } -// } -// } + + fun putChattingRoomAlarm( + roomId: Long, + request: PutChattingRoomAlarmRequest, + ) { + viewModelScope.launch { + val result = putChattingRoomAlarmUseCase(roomId, request) + result + .onSuccess { response -> + _putChattingRoomAlarmResponse.value = response + }.onFailure { exception -> + if (exception is ReissueFailureException) { + _navigateToLogin.value = true + } else { + _errorMessage.value = exception.message + } + } + } + } } From 3303ac3d0a098adc4f2ecdd3ff15f44efcb1920d Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 10 Mar 2026 18:15:42 +0900 Subject: [PATCH 13/14] =?UTF-8?q?refactor:=20ktlint=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/chatting/LeaveChattingRoomUseCase.kt | 3 +-- .../presentation/view/chatting/ChatListAdapter.kt | 4 +--- .../view/chatting/ChattingRoomFragment.kt | 13 ++++++++----- .../view/chatting/ChattingSettingFragment.kt | 6 +++++- .../presentation/view/post/ReadPostFragment.kt | 2 +- .../viewmodel/ChattingRoomViewModel.kt | 14 ++++---------- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt index dcc329a1..86c92963 100644 --- a/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt +++ b/CatchMate/domain/src/main/java/com/catchmate/domain/usecase/chatting/LeaveChattingRoomUseCase.kt @@ -8,6 +8,5 @@ class LeaveChattingRoomUseCase constructor( private val chattingRepository: ChattingRepository, ) { - suspend operator fun invoke(roomId: Long): Result = - chattingRepository.deleteChattingRoom(roomId) + suspend operator fun invoke(roomId: Long): Result = chattingRepository.deleteChattingRoom(roomId) } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt index bc520b08..60adeb0b 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChatListAdapter.kt @@ -75,9 +75,7 @@ class ChatListAdapter( inner class ChattingParticipantViewHolder( private val binding: ViewChattingParticipantAlertBinding, ) : RecyclerView.ViewHolder(binding.root) { - fun bind( - chat: GetChattingMessagesResponse, - ) { + fun bind(chat: GetChattingMessagesResponse) { binding.tvChattingParticipantAlert.text = chat.content } } diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt index aea83a19..863bd9cb 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt @@ -83,7 +83,6 @@ class ChattingRoomFragment : BaseFragment(FragmentC } } - private fun initViewModel() { chattingRoomViewModel.getChattingMessagesResponse.observe(viewLifecycleOwner) { response -> if (response.isEmpty()) { @@ -337,7 +336,10 @@ class ChattingRoomFragment : BaseFragment(FragmentC adapter = crewAdapter layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) } - crewAdapter.submitList((chattingRoomViewModel.getChattingCrewListResponse.value ?: emptyList())) + crewAdapter.submitList( + (chattingRoomViewModel.getChattingCrewListResponse.value + ?: emptyList()) + ) // 버튼 기능 ivSideSheetLeaveChattingRoom.setOnClickListener { @@ -351,8 +353,9 @@ class ChattingRoomFragment : BaseFragment(FragmentC val bundle = Bundle().apply { putString("chattingRoomImage", info.chatRoomImageUrl) - putParcelableArrayList("chattingCrewList", - chattingRoomViewModel.getChattingCrewListResponse.value as ArrayList? + putParcelableArrayList( + "chattingCrewList", + chattingRoomViewModel.getChattingCrewListResponse.value as ArrayList?, ) putLong("loginUserId", userId) putLong("writerId", info.board.userResponse.userId) @@ -372,7 +375,7 @@ class ChattingRoomFragment : BaseFragment(FragmentC chattingRoomViewModel.chattingRoomInfo.value?.chatRoomId ?: -1, PutChattingRoomAlarmRequest( isNotificationEnabled, - ) + ), ) } layoutSideSheetPostInfo.setOnClickListener { diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt index 90eb5aa3..51b4ef49 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt @@ -70,7 +70,11 @@ class ChattingSettingFragment : private fun getChattingCrewList(): MutableList? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - arguments?.getParcelableArrayList("chattingCrewList", GetChattingCrewListResponse::class.java)?.toMutableList() + arguments?.getParcelableArrayList( + "chattingCrewList", + GetChattingCrewListResponse::class.java, + ) + ?.toMutableList() } else { val parcelable = arguments?.getParcelableArrayList("chattingCrewList") parcelable?.toMutableList() diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt index 7dc5676c..c5676bf4 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/post/ReadPostFragment.kt @@ -233,7 +233,7 @@ class ReadPostFragment : BaseFragment(FragmentReadPostB maxPerson = readPostViewModel.getBoardResponse.value?.maxPerson!!, bookMarked = readPostViewModel.getBoardResponse.value?.bookMarked!!, cheerClub = readPostViewModel.getBoardResponse.value?.cheerClub!!, - gameResponse =readPostViewModel.getBoardResponse.value?.game!!, + gameResponse = readPostViewModel.getBoardResponse.value?.game!!, userResponse = readPostViewModel.getBoardResponse.value?.user!!, ), lastMessage = null, diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt index fe92a61c..ef1ebc9b 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/viewmodel/ChattingRoomViewModel.kt @@ -112,7 +112,7 @@ class ChattingRoomViewModel val stompHeaders = listOf( - StompHeader("Authorization", accessToken) + StompHeader("Authorization", accessToken), ) stompClient?.lifecycle()?.subscribe({ event -> @@ -142,9 +142,7 @@ class ChattingRoomViewModel } } - private fun handleWebSocketOpened( - chatRoomId: Long, - ) { + private fun handleWebSocketOpened(chatRoomId: Long) { // 채팅방 구독 topic = stompClient?.topic("/sub/chat/room/$chatRoomId")?.subscribe({ message -> @@ -176,9 +174,7 @@ class ChattingRoomViewModel }) } - private fun sendIsMsgRead( - chatRoomId: Long, - ) { + private fun sendIsMsgRead(chatRoomId: Long) { viewModelScope.launch { val msg = JSONObject() @@ -189,9 +185,7 @@ class ChattingRoomViewModel } } - fun sendMessage( - request: String, - ) { + fun sendMessage(request: String) { // 전달 성공 시 view의 edt 텍스트 비우기 viewModelScope.launch { stompClient?.send("/pub/chat/message", request)?.subscribe({ From ffd70b443a93f272e641820a0b1889c5a2642659 Mon Sep 17 00:00:00 2001 From: nueijeel Date: Tue, 10 Mar 2026 18:19:43 +0900 Subject: [PATCH 14/14] =?UTF-8?q?refactor:=20ktlint=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/view/chatting/ChattingRoomFragment.kt | 6 ++++-- .../view/chatting/ChattingSettingFragment.kt | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt index 863bd9cb..beeead61 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingRoomFragment.kt @@ -337,8 +337,10 @@ class ChattingRoomFragment : BaseFragment(FragmentC layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) } crewAdapter.submitList( - (chattingRoomViewModel.getChattingCrewListResponse.value - ?: emptyList()) + ( + chattingRoomViewModel.getChattingCrewListResponse.value + ?: emptyList() + ), ) // 버튼 기능 diff --git a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt index 51b4ef49..0ad8e065 100644 --- a/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt +++ b/CatchMate/presentation/src/main/java/com/catchmate/presentation/view/chatting/ChattingSettingFragment.kt @@ -70,11 +70,11 @@ class ChattingSettingFragment : private fun getChattingCrewList(): MutableList? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - arguments?.getParcelableArrayList( - "chattingCrewList", - GetChattingCrewListResponse::class.java, - ) - ?.toMutableList() + arguments + ?.getParcelableArrayList( + "chattingCrewList", + GetChattingCrewListResponse::class.java, + )?.toMutableList() } else { val parcelable = arguments?.getParcelableArrayList("chattingCrewList") parcelable?.toMutableList()