fix(deeplink): 커뮤니티 댓글 딥링크를 보강한다
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user