fix(deeplink): 커뮤니티 댓글 딥링크를 보강한다

This commit is contained in:
Yu Sung
2026-03-13 21:39:45 +09:00
parent 3d4f67dbd5
commit de627e1700
5 changed files with 192 additions and 11 deletions

View File

@@ -144,6 +144,11 @@ struct CreatorCommunityAllView: View {
.sodaToast(isPresented: $playerManager.isShowPopup, message: playerManager.errorMessage, autohideIn: 2)
.onAppear {
viewModel.creatorId = creatorId
if let pendingPostId = AppState.shared.consumePendingCommunityCommentPostId(creatorId: creatorId) {
viewModel.openCommentListForDeepLink(postId: pendingPostId)
}
viewModel.getCommunityPostList()
}
.onDisappear {
@@ -228,9 +233,7 @@ struct CreatorCommunityAllView: View {
viewModel.communityPostLike(postId: item.postId)
},
onClickComment: {
viewModel.postId = item.postId
viewModel.isShowSecret = item.price > 0 && item.existOrdered && item.creatorId != UserDefaults.int(forKey: .userId)
viewModel.isShowCommentListView = true
viewModel.openCommentList(item: item)
},
onClickWriteComment: { comment, isSecret in
viewModel.createCommunityPostComment(

View File

@@ -117,6 +117,27 @@ class CreatorCommunityAllViewModel: ObservableObject {
.store(in: &subscription)
}
}
func openCommentList(item: GetCommunityPostListResponse) {
postId = item.postId
isShowSecret = shouldShowSecretCommentOption(item: item)
isShowCommentListView = true
}
func openCommentListForDeepLink(postId: Int) {
guard postId > 0 else {
return
}
if let targetPost = communityPostList.first(where: { $0.postId == postId }) {
openCommentList(item: targetPost)
return
}
self.postId = postId
self.isShowSecret = false
self.isShowCommentListView = true
}
func communityPostLike(postId: Int) {
repository.communityPostLike(postId: postId)
@@ -315,4 +336,8 @@ class CreatorCommunityAllViewModel: ObservableObject {
.store(in: &subscription)
}
}
private func shouldShowSecretCommentOption(item: GetCommunityPostListResponse) -> Bool {
item.price > 0 && item.existOrdered && item.creatorId != UserDefaults.int(forKey: .userId)
}
}