feat(chat): 채팅방 UI 모델 매핑을 추가한다

This commit is contained in:
2026-06-10 11:30:00 +09:00
parent 50f0fb3d15
commit 5a17d7d2f6
3 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package kr.co.vividnext.sodalive.v2.main.chat.model
import android.content.Context
import kr.co.vividnext.sodalive.v2.main.chat.data.ChatRoomListItemResponse
fun ChatRoomListItemResponse.toUiItem(context: Context): ChatRoomListUiItem? {
val type = when (chatType) {
ChatRoomType.AI.name -> ChatRoomType.AI
ChatRoomType.DM.name -> ChatRoomType.DM
else -> return null
}
return ChatRoomListUiItem(
roomId = roomId,
chatType = type,
targetName = targetName,
targetImageUrl = targetImageUrl,
lastMessage = lastMessage,
lastMessageTimeText = formatChatRoomLastMessageTime(context, lastMessageAt),
showDirectBadge = type == ChatRoomType.DM
)
}
fun List<ChatRoomListItemResponse>.toUiItems(context: Context): List<ChatRoomListUiItem> = mapNotNull { it.toUiItem(context) }

View File

@@ -0,0 +1,29 @@
package kr.co.vividnext.sodalive.v2.main.chat.model
enum class ChatRoomType {
AI,
DM
}
data class ChatRoomListUiItem(
val roomId: Long,
val chatType: ChatRoomType,
val targetName: String,
val targetImageUrl: String,
val lastMessage: String,
val lastMessageTimeText: String,
val showDirectBadge: Boolean
)
sealed class ChatRoomListUiState {
data object Loading : ChatRoomListUiState()
data class Content(
val items: List<ChatRoomListUiItem>,
val isAppending: Boolean = false
) : ChatRoomListUiState()
data object Empty : ChatRoomListUiState()
data class Error(val message: String?) : ChatRoomListUiState()
}