fix(creator): 커뮤니티 게시글 표시 정책을 보정한다
This commit is contained in:
@@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.v2.creator.channel.community
|
|||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.orhanobut.logger.Logger
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||||
@@ -127,7 +126,6 @@ class CreatorChannelCommunityViewModel(
|
|||||||
{
|
{
|
||||||
if (generation != requestGeneration) return@subscribe
|
if (generation != requestGeneration) return@subscribe
|
||||||
|
|
||||||
it.message?.let { message -> Logger.e(message) }
|
|
||||||
val current = _communityStateLiveData.value as? CreatorChannelCommunityUiState.Content
|
val current = _communityStateLiveData.value as? CreatorChannelCommunityUiState.Content
|
||||||
_communityStateLiveData.value = if (current != null && page > FIRST_PAGE) {
|
_communityStateLiveData.value = if (current != null && page > FIRST_PAGE) {
|
||||||
current.copy(isLoadingMore = false, paginationErrorMessage = it.message)
|
current.copy(isLoadingMore = false, paginationErrorMessage = it.message)
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
|
|||||||
): CreatorChannelCommunityPostUiModel {
|
): CreatorChannelCommunityPostUiModel {
|
||||||
val isLocked = price > 0 && !existOrdered && !isOwner
|
val isLocked = price > 0 && !existOrdered && !isOwner
|
||||||
val showOwnerActions = isOwner && creatorId == currentUserId
|
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(
|
return CreatorChannelCommunityPostUiModel(
|
||||||
postId = postId,
|
postId = postId,
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
@@ -28,7 +29,7 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
|
|||||||
creatorProfileUrl = creatorProfileUrl,
|
creatorProfileUrl = creatorProfileUrl,
|
||||||
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
|
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
|
||||||
content = content,
|
content = content,
|
||||||
imageUrl = imageUrl,
|
imageUrl = visibleImageUrl,
|
||||||
audioUrl = audioUrl,
|
audioUrl = audioUrl,
|
||||||
price = price,
|
price = price,
|
||||||
existOrdered = existOrdered,
|
existOrdered = existOrdered,
|
||||||
@@ -36,18 +37,22 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
|
|||||||
commentCount = commentCount,
|
commentCount = commentCount,
|
||||||
showComment = isCommentAvailable,
|
showComment = isCommentAvailable,
|
||||||
showNotice = isPinned,
|
showNotice = isPinned,
|
||||||
|
isPinned = isPinned,
|
||||||
isLocked = isLocked,
|
isLocked = isLocked,
|
||||||
showOwnerMore = showOwnerActions,
|
showOwnerMore = showOwnerActions,
|
||||||
showOwnerTopPrice = showOwnerActions && price > 0,
|
showOwnerTopPrice = showOwnerActions && price > 0,
|
||||||
showPlayButton = showPlayButton,
|
showPlayButton = showPlayButton,
|
||||||
gridPreviewText = content.toGridPreviewText(),
|
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
|
isLocked -> CreatorChannelCommunityImageMode.LockedGray
|
||||||
imageUrl.isNullOrBlank() -> CreatorChannelCommunityImageMode.TextPreview
|
visibleImageUrl.isNullOrBlank() -> CreatorChannelCommunityImageMode.TextPreview
|
||||||
else -> CreatorChannelCommunityImageMode.Image
|
else -> CreatorChannelCommunityImageMode.Image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ data class CreatorChannelCommunityPostUiModel(
|
|||||||
val commentCount: Int,
|
val commentCount: Int,
|
||||||
val showComment: Boolean,
|
val showComment: Boolean,
|
||||||
val showNotice: Boolean,
|
val showNotice: Boolean,
|
||||||
|
val isPinned: Boolean,
|
||||||
val isLocked: Boolean,
|
val isLocked: Boolean,
|
||||||
val showOwnerMore: Boolean,
|
val showOwnerMore: Boolean,
|
||||||
val showOwnerTopPrice: Boolean,
|
val showOwnerTopPrice: Boolean,
|
||||||
|
|||||||
@@ -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 kr.co.vividnext.sodalive.v2.creator.channel.community.model.toCommunityPostUiModels
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -71,10 +72,26 @@ class CreatorChannelCommunityMapperTest {
|
|||||||
).toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
|
).toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
|
||||||
|
|
||||||
assertTrue(item.isLocked)
|
assertTrue(item.isLocked)
|
||||||
|
assertNull(item.imageUrl)
|
||||||
assertEquals(CreatorChannelCommunityImageMode.LockedGray, item.imageMode)
|
assertEquals(CreatorChannelCommunityImageMode.LockedGray, item.imageMode)
|
||||||
assertFalse(item.showPlayButton)
|
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
|
@Test
|
||||||
fun `본인 또는 구매한 사용자는 이미지와 오디오가 있으면 play button을 표시한다`() {
|
fun `본인 또는 구매한 사용자는 이미지와 오디오가 있으면 play button을 표시한다`() {
|
||||||
val ownerItem = listOf(
|
val ownerItem = listOf(
|
||||||
|
|||||||
Reference in New Issue
Block a user