refactor(chat): 채팅방 시간 표시 책임을 분리한다
This commit is contained in:
@@ -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() }
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user