응원글 전체보기 - 응원글 삭제기능 추가

This commit is contained in:
Yu Sung
2023-09-09 00:38:55 +09:00
parent 948b1fd2b3
commit 1f992a11dc
5 changed files with 39 additions and 71 deletions

View File

@@ -17,8 +17,8 @@ final class UserProfileFanTalkViewModel: ObservableObject {
@Published var cheersList = [GetCheersResponseItem]()
@Published var reportCheersId = 0
@Published var isShowCheersReportMenu = false
@Published var isShowCheersReportView = false
@Published var isShowCheersDeleteView = false
var errorPopup: ((String) -> Void)?
var setLoading: ((Bool) -> Void)?
@@ -224,8 +224,17 @@ final class UserProfileFanTalkViewModel: ObservableObject {
.store(in: &subscription)
}
func modifyCheers(cheersId: Int, creatorId: Int, cheersReplyContent: String) {
if cheersReplyContent.trimmingCharacters(in: .whitespaces).isEmpty {
func modifyCheers(cheersId: Int, creatorId: Int, cheersContent: String? = nil, isActive: Bool? = nil) {
if cheersContent == nil && isActive == nil {
if let errorPopup = errorPopup {
errorPopup("변경사항이 없습니다.")
} else {
errorMessage = "변경사항이 없습니다."
isShowPopup = true
}
}
if let cheersContent = cheersContent, cheersContent.trimmingCharacters(in: .whitespaces).isEmpty {
if let errorPopup = errorPopup {
errorPopup("내용을 입력하세요")
} else {
@@ -241,7 +250,7 @@ final class UserProfileFanTalkViewModel: ObservableObject {
}
isLoading = true
repository.modifyCheers(cheersId: cheersId, content: cheersReplyContent, isActive: nil)
repository.modifyCheers(cheersId: cheersId, content: cheersContent, isActive: isActive)
.sink { result in
switch result {
case .finished: