fix(creator): 팬Talk 답글 수정을 확인한다
This commit is contained in:
@@ -28,6 +28,7 @@ final class CreatorChannelReplyDetailViewModel: ObservableObject {
|
||||
@Published var editingItem: CreatorChannelReplyDetailDisplayItem?
|
||||
@Published var deletingItem: CreatorChannelReplyDetailDisplayItem?
|
||||
@Published var isShowDeleteDialog = false
|
||||
@Published var isShowReplaceReplyDialog = false
|
||||
|
||||
var isSendEnabled: Bool {
|
||||
replyText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false
|
||||
@@ -53,9 +54,9 @@ final class CreatorChannelReplyDetailViewModel: ObservableObject {
|
||||
fetchCommunityReplies(reset: true)
|
||||
case .fanTalk(let creatorId, let parentFanTalk):
|
||||
parentItem = CreatorChannelReplyDetailDisplayItem(fanTalk: parentFanTalk)
|
||||
replies = parentFanTalk.creatorReplies.map {
|
||||
replies = parentFanTalk.latestCreatorReply.map {
|
||||
CreatorChannelReplyDetailDisplayItem(fanTalkReply: $0, creatorId: creatorId)
|
||||
}
|
||||
}.map { [$0] } ?? []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +119,23 @@ final class CreatorChannelReplyDetailViewModel: ObservableObject {
|
||||
|
||||
if let editingItem {
|
||||
modify(item: editingItem)
|
||||
} else if existingFanTalkCreatorReply != nil {
|
||||
isShowReplaceReplyDialog = true
|
||||
} else {
|
||||
createReply()
|
||||
}
|
||||
}
|
||||
|
||||
func dismissReplaceReplyDialog() {
|
||||
isShowReplaceReplyDialog = false
|
||||
}
|
||||
|
||||
func confirmReplaceReply() {
|
||||
guard let existingFanTalkCreatorReply, isLoading == false else { return }
|
||||
isShowReplaceReplyDialog = false
|
||||
modify(item: existingFanTalkCreatorReply)
|
||||
}
|
||||
|
||||
func confirmDelete() {
|
||||
guard let deletingItem, isLoading == false else { return }
|
||||
isShowDeleteDialog = false
|
||||
@@ -328,9 +341,9 @@ final class CreatorChannelReplyDetailViewModel: ObservableObject {
|
||||
if let data = decoded.data, decoded.success {
|
||||
if let fanTalk = data.fanTalks.first(where: { $0.fanTalkId == parentFanTalk.fanTalkId }) {
|
||||
self.isLoading = false
|
||||
self.replies = fanTalk.creatorReplies.map {
|
||||
self.replies = fanTalk.latestCreatorReply.map {
|
||||
CreatorChannelReplyDetailDisplayItem(fanTalkReply: $0, creatorId: creatorId)
|
||||
}
|
||||
}.map { [$0] } ?? []
|
||||
} else if data.hasNext {
|
||||
self.fetchFanTalkReplies(page: page + 1)
|
||||
} else {
|
||||
@@ -435,6 +448,11 @@ final class CreatorChannelReplyDetailViewModel: ObservableObject {
|
||||
return false
|
||||
}
|
||||
|
||||
private var existingFanTalkCreatorReply: CreatorChannelReplyDetailDisplayItem? {
|
||||
guard case .fanTalk = context else { return nil }
|
||||
return replies.first { $0.isCreatorReply }
|
||||
}
|
||||
|
||||
private func communityRepliesPublisher(page: Int) -> AnyPublisher<Response, MoyaError> {
|
||||
switch context {
|
||||
case .community(_, _, let parentComment):
|
||||
|
||||
Reference in New Issue
Block a user