fix(creator): 상세 댓글 잠금을 적용한다

This commit is contained in:
Yu Sung
2026-08-10 18:43:43 +09:00
parent a845b54f0f
commit 57ac574bb9
2 changed files with 14 additions and 9 deletions

View File

@@ -22,7 +22,7 @@ struct CreatorChannelCommunityPostDetailView: View {
onTapPurchase: viewModel.presentPurchaseDialog
)
if detail.isCommentAvailable {
if viewModel.isCommentInteractionAvailable {
Rectangle()
.fill(Color.gray800)
.frame(height: 1)
@@ -83,7 +83,7 @@ struct CreatorChannelCommunityPostDetailView: View {
viewModel.configure(postId: postId, onCommunityRefresh: onCommunityRefresh)
}
.safeAreaInset(edge: .bottom) {
if viewModel.detail?.isCommentAvailable == true {
if viewModel.isCommentInteractionAvailable {
CreatorChannelCommunityPostDetailInputBar(
text: $viewModel.commentText,
isSecret: $viewModel.isSecret,

View File

@@ -33,13 +33,18 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
detail?.creatorId == UserDefaults.int(forKey: .userId)
}
var isCommentInteractionAvailable: Bool {
guard let detail, detail.isCommentAvailable else { return false }
return detail.price <= 0 || detail.existOrdered || isOwnPost
}
var isShowSecret: Bool {
guard let detail else { return false }
return detail.price > 0 && detail.existOrdered && detail.creatorId != UserDefaults.int(forKey: .userId)
}
var isCommentSendEnabled: Bool {
guard detail?.isCommentAvailable == true else { return false }
guard isCommentInteractionAvailable else { return false }
return commentText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false && isLoading == false
}
@@ -102,7 +107,7 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
func fetchNextCommentsIfNeeded(currentComment: CreatorChannelCommunityCommentResponse) {
guard comments.last?.commentId == currentComment.commentId else { return }
guard detail?.isCommentAvailable == true else { return }
guard isCommentInteractionAvailable else { return }
guard hasNext, isLoadingNextPage == false, isLoading == false else { return }
guard postId > 0 else { return }
@@ -227,7 +232,7 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
}
func sendComment() {
guard isCommentSendEnabled else { return }
guard isCommentInteractionAvailable, isCommentSendEnabled else { return }
if let editingComment {
modify(comment: editingComment)
@@ -253,7 +258,7 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
}
func beginEditing(_ comment: CreatorChannelCommunityCommentResponse) {
guard canEdit(comment) else { return }
guard isCommentInteractionAvailable, canEdit(comment) else { return }
selectedComment = nil
editingComment = comment
commentText = comment.content
@@ -265,14 +270,14 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
}
func presentDeleteDialog(_ comment: CreatorChannelCommunityCommentResponse) {
guard canDelete(comment) else { return }
guard isCommentInteractionAvailable, canDelete(comment) else { return }
selectedComment = nil
deletingComment = comment
isShowDeleteDialog = true
}
func confirmDelete() {
guard let deletingComment, isLoading == false else { return }
guard isCommentInteractionAvailable, let deletingComment, isLoading == false else { return }
isShowDeleteDialog = false
delete(comment: deletingComment)
}
@@ -284,7 +289,7 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
hasNext = data.comments.hasNext
hasLoaded = true
if data.isCommentAvailable {
if isCommentInteractionAvailable {
comments = data.comments.comments
} else {
comments = []