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
tvCreatorChannelCommunityDetailTime.text = post.createdAtText
tvCreatorChannelCommunityDetailBody.text = post.content
layoutCreatorChannelCommunityDetailReaction.isVisible = post.showReaction || content.isCommentAvailable
tvCreatorChannelCommunityDetailLikeCount.text = post.likeCount.moneyFormat()
tvCreatorChannelCommunityDetailCommentCount.text = post.commentCount.moneyFormat()
tvCreatorChannelCommunityDetailCommentHeader.text = getString(
R.string.creator_channel_community_comment_header,
post.commentCount.moneyFormat()
)
ivCreatorChannelCommunityDetailHeart.isVisible = post.showReaction
tvCreatorChannelCommunityDetailLikeCount.isVisible = post.showReaction
ivCreatorChannelCommunityDetailHeart.setImageResource(
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 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) }
} else {
emptyList()
}
_detailStateLiveData.value = CreatorChannelCommunityDetailUiState.Content(
post = data.toUiModel(),
isCommentAvailable = data.isCommentAvailable,
isCommentInputVisible = data.isCommentAvailable,
post = post,
isCommentAvailable = isCommentVisible,
isCommentInputVisible = isCommentVisible,
comments = comments,
commentPage = data.comments.page,
hasNextComment = data.isCommentAvailable && data.comments.hasNext
hasNextComment = isCommentVisible && data.comments.hasNext
)
}
@@ -439,7 +441,8 @@ class CreatorChannelCommunityDetailViewModel(
isLiked = isLiked,
isPinned = isPinned,
isLocked = isLocked(),
showPaywall = isLocked()
showPaywall = isLocked(),
showReaction = !isLocked()
)
private fun CreatorChannelCommunityPostDetailResponse.isLocked(): Boolean {
@@ -524,7 +527,8 @@ data class CreatorChannelCommunityPostDetailUiModel(
val isLiked: Boolean,
val isPinned: Boolean,
val isLocked: Boolean,
val showPaywall: Boolean
val showPaywall: Boolean,
val showReaction: Boolean
)
data class CreatorChannelCommunityCommentUiModel(

View File

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

View File

@@ -373,6 +373,36 @@ class CreatorChannelCommunityDetailViewModelTest {
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
fun `채널 작성자는 유료 미구매 게시물도 이미지와 오디오 URL을 볼 수 있다`() {
SharedPreferenceManager.userId = 999L