콘텐츠 댓글 수정 오류

- 댓글 수정 모드 상태에서 다른 댓글 쓰기 혹은 삭제 등의 액션을 해서 댓글 수의 변화가 있을 때 내 글이 아닌 다른 사람의 글이 수정 모드로 보이는 버그 수정
This commit is contained in:
Yu Sung 2025-03-18 22:52:39 +09:00
parent d5e1acb1c3
commit dfe17c7797
5 changed files with 45 additions and 34 deletions

View File

@ -120,11 +120,11 @@ struct AudioContentCommentItemView: View {
.frame(width: 35, height: 35) .frame(width: 35, height: 35)
.padding(6.7) .padding(6.7)
.onTapGesture { .onTapGesture {
isModeModify = false
hideKeyboard() hideKeyboard()
if commentItem.comment != comment { if commentItem.comment != comment {
modifyComment(commentItem.id, comment) modifyComment(commentItem.id, comment)
} }
isModeModify = false
} }
} }
.background(Color.gray23) .background(Color.gray23)
@ -188,6 +188,7 @@ struct AudioContentCommentItemView: View {
.font(.custom(Font.medium.rawValue, size: 14)) .font(.custom(Font.medium.rawValue, size: 14))
.foregroundColor(Color.gray77) .foregroundColor(Color.gray77)
.onTapGesture { .onTapGesture {
isModeModify = false
onClickDelete(commentItem.id) onClickDelete(commentItem.id)
isShowPopupMenu = false isShowPopupMenu = false
} }

View File

@ -122,11 +122,11 @@ struct AudioContentCommentListView: View {
.padding(.bottom, 13.3) .padding(.bottom, 13.3)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
if !viewModel.isRegisterComment {
ScrollView(.vertical, showsIndicators: false) { ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 13.3) { LazyVStack(spacing: 13.3) {
ForEach(0..<viewModel.commentList.count, id: \.self) { index in ForEach(0..<viewModel.commentList.count, id: \.self) { index in
let comment = viewModel.commentList[index] let comment = viewModel.commentList[index]
VStack {
AudioContentCommentItemView( AudioContentCommentItemView(
contentCreatorId: creatorId, contentCreatorId: creatorId,
audioContentId: audioContentId, audioContentId: audioContentId,

View File

@ -14,6 +14,7 @@ class AudioContentCommentListViewModel: ObservableObject {
private let repository = ContentRepository() private let repository = ContentRepository()
private var subscription = Set<AnyCancellable>() private var subscription = Set<AnyCancellable>()
@Published var isRegisterComment = false
@Published var isLoading = false @Published var isLoading = false
@Published var errorMessage = "" @Published var errorMessage = ""
@Published var isShowPopup = false @Published var isShowPopup = false
@ -85,6 +86,7 @@ class AudioContentCommentListViewModel: ObservableObject {
} }
isLoading = true isLoading = true
isRegisterComment = true
repository.registerComment(audioContentId: audioContentId, comment: comment, isSecret: isSecret) repository.registerComment(audioContentId: audioContentId, comment: comment, isSecret: isSecret)
.sink { result in .sink { result in
@ -96,6 +98,7 @@ class AudioContentCommentListViewModel: ObservableObject {
} }
} receiveValue: { [unowned self] response in } receiveValue: { [unowned self] response in
self.isLoading = false self.isLoading = false
self.isRegisterComment = false
let responseData = response.data let responseData = response.data
do { do {
@ -103,6 +106,7 @@ class AudioContentCommentListViewModel: ObservableObject {
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
if decoded.success { if decoded.success {
self.commentList.removeAll()
self.comment = "" self.comment = ""
self.page = 1 self.page = 1
self.isLast = false self.isLast = false

View File

@ -110,6 +110,7 @@ struct AudioContentListReplyView: View {
.padding(.horizontal, 26.7) .padding(.horizontal, 26.7)
.padding(.bottom, 13.3) .padding(.bottom, 13.3)
if !viewModel.isRegisterComment {
ScrollView(.vertical, showsIndicators: false) { ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 13.3) { LazyVStack(spacing: 13.3) {
ForEach(0..<viewModel.commentList.count, id: \.self) { index in ForEach(0..<viewModel.commentList.count, id: \.self) { index in
@ -143,6 +144,7 @@ struct AudioContentListReplyView: View {
} }
} }
} }
}
.navigationTitle("") .navigationTitle("")
.navigationBarBackButtonHidden() .navigationBarBackButtonHidden()

View File

@ -13,6 +13,7 @@ final class AudioContentListReplyViewModel: ObservableObject {
private let repository = ContentRepository() private let repository = ContentRepository()
private var subscription = Set<AnyCancellable>() private var subscription = Set<AnyCancellable>()
@Published var isRegisterComment = false
@Published var isLoading = false @Published var isLoading = false
@Published var errorMessage = "" @Published var errorMessage = ""
@Published var isShowPopup = false @Published var isShowPopup = false
@ -83,6 +84,7 @@ final class AudioContentListReplyViewModel: ObservableObject {
} }
isLoading = true isLoading = true
isRegisterComment = true
repository.registerComment(audioContentId: audioContentId, comment: comment, parentId: commentId) repository.registerComment(audioContentId: audioContentId, comment: comment, parentId: commentId)
.sink { result in .sink { result in
@ -94,6 +96,7 @@ final class AudioContentListReplyViewModel: ObservableObject {
} }
} receiveValue: { [unowned self] response in } receiveValue: { [unowned self] response in
self.isLoading = false self.isLoading = false
self.isRegisterComment = false
let responseData = response.data let responseData = response.data
do { do {
@ -101,6 +104,7 @@ final class AudioContentListReplyViewModel: ObservableObject {
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
if decoded.success { if decoded.success {
self.commentList.removeAll()
self.comment = "" self.comment = ""
self.page = 1 self.page = 1
self.isLast = false self.isLast = false