refactor(chat): 채팅방 시간 표시 책임을 분리한다

This commit is contained in:
2026-06-10 12:00:18 +09:00
parent 10a74c2e5e
commit ed8a0e9a09
3 changed files with 11 additions and 17 deletions

View File

@@ -1,9 +1,8 @@
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? {
fun ChatRoomListItemResponse.toUiItem(): ChatRoomListUiItem? {
val type = when (chatType) {
ChatRoomType.AI.name -> ChatRoomType.AI
ChatRoomType.DM.name -> ChatRoomType.DM
@@ -16,9 +15,9 @@ fun ChatRoomListItemResponse.toUiItem(context: Context): ChatRoomListUiItem? {
targetName = targetName,
targetImageUrl = targetImageUrl,
lastMessage = lastMessage,
lastMessageTimeText = formatChatRoomLastMessageTime(context, lastMessageAt),
lastMessageAt = lastMessageAt,
showDirectBadge = type == ChatRoomType.DM
)
}
fun List<ChatRoomListItemResponse>.toUiItems(context: Context): List<ChatRoomListUiItem> = mapNotNull { it.toUiItem(context) }
fun List<ChatRoomListItemResponse>.toUiItems(): List<ChatRoomListUiItem> = mapNotNull { it.toUiItem() }

View File

@@ -11,7 +11,7 @@ data class ChatRoomListUiItem(
val targetName: String,
val targetImageUrl: String,
val lastMessage: String,
val lastMessageTimeText: String,
val lastMessageAt: String,
val showDirectBadge: Boolean
)