diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeMappers.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeMappers.kt index 333130c7..1e3897db 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeMappers.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeMappers.kt @@ -7,10 +7,11 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelSnsRespons import java.net.URI fun CreatorChannelHomeResponse.toUiContent(currentMemberId: Long): CreatorChannelHomeUiState.Content { + val isOwner = creator.creatorId == currentMemberId val sections = buildList { currentLive?.let { add(CreatorChannelHomeSection.CurrentLive(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)) } schedules.sortedBy { it.scheduledAtUtc }.take(MAX_SCHEDULE_ITEM_COUNT) .takeIf { it.isNotEmpty() } @@ -35,7 +36,7 @@ fun CreatorChannelHomeResponse.toUiContent(currentMemberId: Long): CreatorChanne isNotify = creator.isNotify, isAiChatAvailable = creator.isAiChatAvailable, isDmAvailable = creator.isDmAvailable, - isOwner = creator.creatorId == currentMemberId + isOwner = isOwner ), tabs = CreatorChannelTab.entries, sections = sections diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeUiModels.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeUiModels.kt index 59b1db77..87c4ddda 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeUiModels.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelHomeUiModels.kt @@ -49,7 +49,10 @@ data class CreatorChannelHeaderUiModel( sealed interface CreatorChannelHomeSection { data class CurrentLive(val live: CreatorChannelLiveResponse) : CreatorChannelHomeSection data class LatestAudioContent(val audioContent: CreatorChannelAudioContentResponse) : CreatorChannelHomeSection - data class Donations(val donations: List) : CreatorChannelHomeSection + data class Donations( + val donations: List, + val isOwner: Boolean + ) : CreatorChannelHomeSection data class Notices(val notices: List) : CreatorChannelHomeSection data class Schedules(val schedules: List) : CreatorChannelHomeSection data class AudioContents(val audioContents: List) : CreatorChannelHomeSection diff --git a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelHomeMapperTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelHomeMapperTest.kt index 64417036..4f6bda7a 100644 --- a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelHomeMapperTest.kt +++ b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelHomeMapperTest.kt @@ -53,7 +53,16 @@ class CreatorChannelHomeMapperTest { } @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().single().isOwner) + assertFalse(visitorContent.sections.filterIsInstance().single().isOwner) + } + + @Test + fun `null 단건 콘텐츠와 빈 리스트와 blank SNS는 후원 empty와 팬Talk empty section을 생성한다`() { val content = response( currentLive = null, latestAudioContent = null, @@ -76,7 +85,8 @@ class CreatorChannelHomeMapperTest { assertFalse(content.sections.any { it is CreatorChannelHomeSection.CurrentLive }) assertFalse(content.sections.any { it is CreatorChannelHomeSection.LatestAudioContent }) - assertFalse(content.sections.any { it is CreatorChannelHomeSection.Donations }) + val donations = content.sections.filterIsInstance().single() + assertTrue(donations.donations.isEmpty()) assertFalse(content.sections.any { it is CreatorChannelHomeSection.Notices }) assertFalse(content.sections.any { it is CreatorChannelHomeSection.Schedules }) assertFalse(content.sections.any { it is CreatorChannelHomeSection.AudioContents })