feat(creator): FanTalk 탭 UI 모델 매핑을 추가한다
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model
|
||||
|
||||
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkResponse
|
||||
|
||||
fun List<CreatorChannelFanTalkResponse>.toFanTalkUiModels(
|
||||
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter,
|
||||
isOwner: Boolean,
|
||||
currentUserId: Long
|
||||
): List<CreatorChannelFanTalkUiModel> = map {
|
||||
it.toFanTalkUiModel(relativeTimeTextFormatter, isOwner, currentUserId)
|
||||
}
|
||||
|
||||
private fun CreatorChannelFanTalkResponse.toFanTalkUiModel(
|
||||
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter,
|
||||
isOwner: Boolean,
|
||||
currentUserId: Long
|
||||
) = CreatorChannelFanTalkUiModel(
|
||||
fanTalkId = fanTalkId,
|
||||
writerId = writerId,
|
||||
writerNickname = writerNickname,
|
||||
writerProfileImageUrl = writerProfileImageUrl,
|
||||
content = content,
|
||||
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
|
||||
reply = creatorReplies.firstOrNull()?.toReplyUiModel(relativeTimeTextFormatter),
|
||||
rightAction = toRightAction(isOwner = isOwner, currentUserId = currentUserId)
|
||||
)
|
||||
|
||||
private fun CreatorChannelFanTalkReplyResponse.toReplyUiModel(
|
||||
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
|
||||
) = CreatorChannelFanTalkReplyUiModel(
|
||||
fanTalkId = fanTalkId,
|
||||
writerId = writerId,
|
||||
writerNickname = writerNickname,
|
||||
writerProfileImageUrl = writerProfileImageUrl,
|
||||
content = content,
|
||||
createdAtText = relativeTimeTextFormatter.format(createdAtUtc)
|
||||
)
|
||||
|
||||
private fun CreatorChannelFanTalkResponse.toRightAction(
|
||||
isOwner: Boolean,
|
||||
currentUserId: Long
|
||||
): CreatorChannelFanTalkRightAction = when {
|
||||
writerId == currentUserId -> CreatorChannelFanTalkRightAction.OwnerMore(showEdit = true, showDelete = true)
|
||||
isOwner -> CreatorChannelFanTalkRightAction.OwnerMore(showEdit = false, showDelete = true)
|
||||
else -> CreatorChannelFanTalkRightAction.Report
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model
|
||||
|
||||
data class CreatorChannelFanTalkUiModel(
|
||||
val fanTalkId: Long,
|
||||
val writerId: Long,
|
||||
val writerNickname: String,
|
||||
val writerProfileImageUrl: String,
|
||||
val content: String,
|
||||
val createdAtText: String,
|
||||
val reply: CreatorChannelFanTalkReplyUiModel?,
|
||||
val rightAction: CreatorChannelFanTalkRightAction
|
||||
)
|
||||
|
||||
data class CreatorChannelFanTalkReplyUiModel(
|
||||
val fanTalkId: Long,
|
||||
val writerId: Long,
|
||||
val writerNickname: String,
|
||||
val writerProfileImageUrl: String,
|
||||
val content: String,
|
||||
val createdAtText: String
|
||||
)
|
||||
|
||||
sealed interface CreatorChannelFanTalkRightAction {
|
||||
data object Report : CreatorChannelFanTalkRightAction
|
||||
data class OwnerMore(
|
||||
val showEdit: Boolean,
|
||||
val showDelete: Boolean
|
||||
) : CreatorChannelFanTalkRightAction
|
||||
}
|
||||
Reference in New Issue
Block a user