feat(creator): 채널 후원 empty 상태를 매핑한다
This commit is contained in:
@@ -7,10 +7,11 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelSnsRespons
|
|||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
fun CreatorChannelHomeResponse.toUiContent(currentMemberId: Long): CreatorChannelHomeUiState.Content {
|
fun CreatorChannelHomeResponse.toUiContent(currentMemberId: Long): CreatorChannelHomeUiState.Content {
|
||||||
|
val isOwner = creator.creatorId == currentMemberId
|
||||||
val sections = buildList {
|
val sections = buildList {
|
||||||
currentLive?.let { add(CreatorChannelHomeSection.CurrentLive(it)) }
|
currentLive?.let { add(CreatorChannelHomeSection.CurrentLive(it)) }
|
||||||
latestAudioContent?.let { add(CreatorChannelHomeSection.LatestAudioContent(it)) }
|
latestAudioContent?.let { add(CreatorChannelHomeSection.LatestAudioContent(it)) }
|
||||||
channelDonations.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Donations(it)) }
|
add(CreatorChannelHomeSection.Donations(donations = channelDonations, isOwner = isOwner))
|
||||||
notices.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Notices(it)) }
|
notices.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Notices(it)) }
|
||||||
schedules.sortedBy { it.scheduledAtUtc }.take(MAX_SCHEDULE_ITEM_COUNT)
|
schedules.sortedBy { it.scheduledAtUtc }.take(MAX_SCHEDULE_ITEM_COUNT)
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
@@ -35,7 +36,7 @@ fun CreatorChannelHomeResponse.toUiContent(currentMemberId: Long): CreatorChanne
|
|||||||
isNotify = creator.isNotify,
|
isNotify = creator.isNotify,
|
||||||
isAiChatAvailable = creator.isAiChatAvailable,
|
isAiChatAvailable = creator.isAiChatAvailable,
|
||||||
isDmAvailable = creator.isDmAvailable,
|
isDmAvailable = creator.isDmAvailable,
|
||||||
isOwner = creator.creatorId == currentMemberId
|
isOwner = isOwner
|
||||||
),
|
),
|
||||||
tabs = CreatorChannelTab.entries,
|
tabs = CreatorChannelTab.entries,
|
||||||
sections = sections
|
sections = sections
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ data class CreatorChannelHeaderUiModel(
|
|||||||
sealed interface CreatorChannelHomeSection {
|
sealed interface CreatorChannelHomeSection {
|
||||||
data class CurrentLive(val live: CreatorChannelLiveResponse) : CreatorChannelHomeSection
|
data class CurrentLive(val live: CreatorChannelLiveResponse) : CreatorChannelHomeSection
|
||||||
data class LatestAudioContent(val audioContent: CreatorChannelAudioContentResponse) : CreatorChannelHomeSection
|
data class LatestAudioContent(val audioContent: CreatorChannelAudioContentResponse) : CreatorChannelHomeSection
|
||||||
data class Donations(val donations: List<CreatorChannelDonationResponse>) : CreatorChannelHomeSection
|
data class Donations(
|
||||||
|
val donations: List<CreatorChannelDonationResponse>,
|
||||||
|
val isOwner: Boolean
|
||||||
|
) : CreatorChannelHomeSection
|
||||||
data class Notices(val notices: List<CreatorChannelCommunityPostResponse>) : CreatorChannelHomeSection
|
data class Notices(val notices: List<CreatorChannelCommunityPostResponse>) : CreatorChannelHomeSection
|
||||||
data class Schedules(val schedules: List<CreatorChannelScheduleResponse>) : CreatorChannelHomeSection
|
data class Schedules(val schedules: List<CreatorChannelScheduleResponse>) : CreatorChannelHomeSection
|
||||||
data class AudioContents(val audioContents: List<CreatorChannelAudioContentResponse>) : CreatorChannelHomeSection
|
data class AudioContents(val audioContents: List<CreatorChannelAudioContentResponse>) : CreatorChannelHomeSection
|
||||||
|
|||||||
@@ -53,7 +53,16 @@ class CreatorChannelHomeMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `null 단건 콘텐츠와 빈 리스트와 blank SNS는 팬Talk empty section만 생성한다`() {
|
fun `본인 채널 여부를 후원 section에도 매핑한다`() {
|
||||||
|
val ownerContent = response().toUiContent(currentMemberId = 100L)
|
||||||
|
val visitorContent = response().toUiContent(currentMemberId = 1L)
|
||||||
|
|
||||||
|
assertTrue(ownerContent.sections.filterIsInstance<CreatorChannelHomeSection.Donations>().single().isOwner)
|
||||||
|
assertFalse(visitorContent.sections.filterIsInstance<CreatorChannelHomeSection.Donations>().single().isOwner)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `null 단건 콘텐츠와 빈 리스트와 blank SNS는 후원 empty와 팬Talk empty section을 생성한다`() {
|
||||||
val content = response(
|
val content = response(
|
||||||
currentLive = null,
|
currentLive = null,
|
||||||
latestAudioContent = null,
|
latestAudioContent = null,
|
||||||
@@ -76,7 +85,8 @@ class CreatorChannelHomeMapperTest {
|
|||||||
|
|
||||||
assertFalse(content.sections.any { it is CreatorChannelHomeSection.CurrentLive })
|
assertFalse(content.sections.any { it is CreatorChannelHomeSection.CurrentLive })
|
||||||
assertFalse(content.sections.any { it is CreatorChannelHomeSection.LatestAudioContent })
|
assertFalse(content.sections.any { it is CreatorChannelHomeSection.LatestAudioContent })
|
||||||
assertFalse(content.sections.any { it is CreatorChannelHomeSection.Donations })
|
val donations = content.sections.filterIsInstance<CreatorChannelHomeSection.Donations>().single()
|
||||||
|
assertTrue(donations.donations.isEmpty())
|
||||||
assertFalse(content.sections.any { it is CreatorChannelHomeSection.Notices })
|
assertFalse(content.sections.any { it is CreatorChannelHomeSection.Notices })
|
||||||
assertFalse(content.sections.any { it is CreatorChannelHomeSection.Schedules })
|
assertFalse(content.sections.any { it is CreatorChannelHomeSection.Schedules })
|
||||||
assertFalse(content.sections.any { it is CreatorChannelHomeSection.AudioContents })
|
assertFalse(content.sections.any { it is CreatorChannelHomeSection.AudioContents })
|
||||||
|
|||||||
Reference in New Issue
Block a user