fix(creator): 커뮤니티 게시글 표시 정책을 보정한다

This commit is contained in:
2026-06-22 00:36:42 +09:00
parent 7ccc676192
commit 318944fbfe
4 changed files with 28 additions and 7 deletions

View File

@@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.v2.creator.channel.community
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.orhanobut.logger.Logger
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.base.BaseViewModel
@@ -127,7 +126,6 @@ class CreatorChannelCommunityViewModel(
{
if (generation != requestGeneration) return@subscribe
it.message?.let { message -> Logger.e(message) }
val current = _communityStateLiveData.value as? CreatorChannelCommunityUiState.Content
_communityStateLiveData.value = if (current != null && page > FIRST_PAGE) {
current.copy(isLoadingMore = false, paginationErrorMessage = it.message)

View File

@@ -20,7 +20,8 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
): CreatorChannelCommunityPostUiModel {
val isLocked = price > 0 && !existOrdered && !isOwner
val showOwnerActions = isOwner && creatorId == currentUserId
val showPlayButton = !isLocked && !audioUrl.isNullOrBlank() && !imageUrl.isNullOrBlank()
val visibleImageUrl = imageUrl.takeUnless { isLocked }
val showPlayButton = !isLocked && !audioUrl.isNullOrBlank() && !visibleImageUrl.isNullOrBlank()
return CreatorChannelCommunityPostUiModel(
postId = postId,
creatorId = creatorId,
@@ -28,7 +29,7 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
creatorProfileUrl = creatorProfileUrl,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
content = content,
imageUrl = imageUrl,
imageUrl = visibleImageUrl,
audioUrl = audioUrl,
price = price,
existOrdered = existOrdered,
@@ -36,18 +37,22 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
commentCount = commentCount,
showComment = isCommentAvailable,
showNotice = isPinned,
isPinned = isPinned,
isLocked = isLocked,
showOwnerMore = showOwnerActions,
showOwnerTopPrice = showOwnerActions && price > 0,
showPlayButton = showPlayButton,
gridPreviewText = content.toGridPreviewText(),
imageMode = toImageMode(isLocked)
imageMode = toImageMode(isLocked, visibleImageUrl)
)
}
private fun CreatorChannelCommunityPostResponse.toImageMode(isLocked: Boolean): CreatorChannelCommunityImageMode = when {
private fun CreatorChannelCommunityPostResponse.toImageMode(
isLocked: Boolean,
visibleImageUrl: String?
): CreatorChannelCommunityImageMode = when {
isLocked -> CreatorChannelCommunityImageMode.LockedGray
imageUrl.isNullOrBlank() -> CreatorChannelCommunityImageMode.TextPreview
visibleImageUrl.isNullOrBlank() -> CreatorChannelCommunityImageMode.TextPreview
else -> CreatorChannelCommunityImageMode.Image
}

View File

@@ -39,6 +39,7 @@ data class CreatorChannelCommunityPostUiModel(
val commentCount: Int,
val showComment: Boolean,
val showNotice: Boolean,
val isPinned: Boolean,
val isLocked: Boolean,
val showOwnerMore: Boolean,
val showOwnerTopPrice: Boolean,

View File

@@ -11,6 +11,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChanne
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.toCommunityPostUiModels
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
@@ -71,10 +72,26 @@ class CreatorChannelCommunityMapperTest {
).toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
assertTrue(item.isLocked)
assertNull(item.imageUrl)
assertEquals(CreatorChannelCommunityImageMode.LockedGray, item.imageMode)
assertFalse(item.showPlayButton)
}
@Test
fun `고정 게시글 여부는 owner more 정책에서 사용할 수 있도록 UI 모델에 보존한다`() {
val pinnedItem = listOf(communityPost(isPinned = true))
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
.single()
val normalItem = listOf(communityPost(isPinned = false))
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
.single()
assertTrue(pinnedItem.isPinned)
assertTrue(pinnedItem.showNotice)
assertFalse(normalItem.isPinned)
assertFalse(normalItem.showNotice)
}
@Test
fun `본인 또는 구매한 사용자는 이미지와 오디오가 있으면 play button을 표시한다`() {
val ownerItem = listOf(