fix(community): 상세 잠금 반응과 댓글을 숨긴다

This commit is contained in:
2026-07-12 09:54:26 +09:00
parent f799449d54
commit 2d8f8cab81
4 changed files with 46 additions and 8 deletions

View File

@@ -140,12 +140,15 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
tvCreatorChannelCommunityDetailNickname.text = post.creatorNickname tvCreatorChannelCommunityDetailNickname.text = post.creatorNickname
tvCreatorChannelCommunityDetailTime.text = post.createdAtText tvCreatorChannelCommunityDetailTime.text = post.createdAtText
tvCreatorChannelCommunityDetailBody.text = post.content tvCreatorChannelCommunityDetailBody.text = post.content
layoutCreatorChannelCommunityDetailReaction.isVisible = post.showReaction || content.isCommentAvailable
tvCreatorChannelCommunityDetailLikeCount.text = post.likeCount.moneyFormat() tvCreatorChannelCommunityDetailLikeCount.text = post.likeCount.moneyFormat()
tvCreatorChannelCommunityDetailCommentCount.text = post.commentCount.moneyFormat() tvCreatorChannelCommunityDetailCommentCount.text = post.commentCount.moneyFormat()
tvCreatorChannelCommunityDetailCommentHeader.text = getString( tvCreatorChannelCommunityDetailCommentHeader.text = getString(
R.string.creator_channel_community_comment_header, R.string.creator_channel_community_comment_header,
post.commentCount.moneyFormat() post.commentCount.moneyFormat()
) )
ivCreatorChannelCommunityDetailHeart.isVisible = post.showReaction
tvCreatorChannelCommunityDetailLikeCount.isVisible = post.showReaction
ivCreatorChannelCommunityDetailHeart.setImageResource( ivCreatorChannelCommunityDetailHeart.setImageResource(
if (post.isLiked) R.drawable.ic_feed_community_heart_fill else R.drawable.ic_feed_community_heart if (post.isLiked) R.drawable.ic_feed_community_heart_fill else R.drawable.ic_feed_community_heart
) )

View File

@@ -304,18 +304,20 @@ class CreatorChannelCommunityDetailViewModel(
} }
val isCreatorOwner = data.creatorId == SharedPreferenceManager.userId val isCreatorOwner = data.creatorId == SharedPreferenceManager.userId
val comments = if (data.isCommentAvailable) { val post = data.toUiModel()
val isCommentVisible = data.isCommentAvailable && !post.isLocked
val comments = if (isCommentVisible) {
data.comments.comments.map { it.toUiModel(isCreatorOwner) } data.comments.comments.map { it.toUiModel(isCreatorOwner) }
} else { } else {
emptyList() emptyList()
} }
_detailStateLiveData.value = CreatorChannelCommunityDetailUiState.Content( _detailStateLiveData.value = CreatorChannelCommunityDetailUiState.Content(
post = data.toUiModel(), post = post,
isCommentAvailable = data.isCommentAvailable, isCommentAvailable = isCommentVisible,
isCommentInputVisible = data.isCommentAvailable, isCommentInputVisible = isCommentVisible,
comments = comments, comments = comments,
commentPage = data.comments.page, commentPage = data.comments.page,
hasNextComment = data.isCommentAvailable && data.comments.hasNext hasNextComment = isCommentVisible && data.comments.hasNext
) )
} }
@@ -439,7 +441,8 @@ class CreatorChannelCommunityDetailViewModel(
isLiked = isLiked, isLiked = isLiked,
isPinned = isPinned, isPinned = isPinned,
isLocked = isLocked(), isLocked = isLocked(),
showPaywall = isLocked() showPaywall = isLocked(),
showReaction = !isLocked()
) )
private fun CreatorChannelCommunityPostDetailResponse.isLocked(): Boolean { private fun CreatorChannelCommunityPostDetailResponse.isLocked(): Boolean {
@@ -524,7 +527,8 @@ data class CreatorChannelCommunityPostDetailUiModel(
val isLiked: Boolean, val isLiked: Boolean,
val isPinned: Boolean, val isPinned: Boolean,
val isLocked: Boolean, val isLocked: Boolean,
val showPaywall: Boolean val showPaywall: Boolean,
val showReaction: Boolean
) )
data class CreatorChannelCommunityCommentUiModel( data class CreatorChannelCommunityCommentUiModel(

View File

@@ -238,6 +238,7 @@
tools:visibility="visible" /> tools:visibility="visible" />
<LinearLayout <LinearLayout
android:id="@+id/layout_creator_channel_community_detail_reaction"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginTop="@dimen/spacing_16" android:layout_marginTop="@dimen/spacing_16"
@@ -256,6 +257,7 @@
style="@style/Typography.Body3" style="@style/Typography.Body3"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginStart="@dimen/spacing_4" android:layout_marginStart="@dimen/spacing_4"
android:includeFontPadding="false" android:includeFontPadding="false"
android:textColor="@color/gray_400" android:textColor="@color/gray_400"
@@ -265,7 +267,6 @@
android:id="@+id/iv_creator_channel_community_detail_heart" android:id="@+id/iv_creator_channel_community_detail_heart"
android:layout_width="18dp" android:layout_width="18dp"
android:layout_height="18dp" android:layout_height="18dp"
android:layout_marginStart="15dp"
android:contentDescription="@null" android:contentDescription="@null"
android:src="@drawable/ic_feed_community_heart" /> android:src="@drawable/ic_feed_community_heart" />

View File

@@ -373,6 +373,36 @@ class CreatorChannelCommunityDetailViewModelTest {
assertTrue(state.post.showPaywall) assertTrue(state.post.showPaywall)
} }
@Test
fun `유료 미구매 게시물은 작성자가 아니면 reaction 현황과 댓글을 숨긴다`() {
SharedPreferenceManager.userId = 10L
stubDetail(
detailResponse(
isCommentAvailable = true,
isLiked = true,
likeCount = 3,
price = 300,
existOrdered = false,
creatorId = 999L,
commentIds = listOf(11L),
commentsHasNext = true
)
)
viewModel.loadDetail(POST_ID)
viewModel.updateCommentInput("hello")
viewModel.submitComment()
val state = viewModel.detailStateLiveData.requireValue() as CreatorChannelCommunityDetailUiState.Content
assertTrue(state.post.isLocked)
assertFalse(state.post.showReaction)
assertFalse(state.isCommentAvailable)
assertFalse(state.isCommentInputVisible)
assertTrue(state.comments.isEmpty())
assertFalse(state.hasNextComment)
verify(legacyRepository, never()).registerComment(any(), any(), any(), any(), any())
}
@Test @Test
fun `채널 작성자는 유료 미구매 게시물도 이미지와 오디오 URL을 볼 수 있다`() { fun `채널 작성자는 유료 미구매 게시물도 이미지와 오디오 URL을 볼 수 있다`() {
SharedPreferenceManager.userId = 999L SharedPreferenceManager.userId = 999L