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

View File

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