콘텐츠 댓글 수정 오류
- 댓글 수정 모드 상태에서 다른 댓글 쓰기 혹은 삭제 등의 액션을 해서 댓글 수의 변화가 있을 때 내 글이 아닌 다른 사람의 글이 수정 모드로 보이는 버그 수정
This commit is contained in:
		| @@ -120,11 +120,11 @@ struct AudioContentCommentItemView: View { | ||||
|                                 .frame(width: 35, height: 35) | ||||
|                                 .padding(6.7) | ||||
|                                 .onTapGesture { | ||||
|                                     isModeModify = false | ||||
|                                     hideKeyboard() | ||||
|                                     if commentItem.comment != comment { | ||||
|                                         modifyComment(commentItem.id, comment) | ||||
|                                     } | ||||
|                                     isModeModify = false | ||||
|                                 } | ||||
|                         } | ||||
|                         .background(Color.gray23) | ||||
| @@ -188,6 +188,7 @@ struct AudioContentCommentItemView: View { | ||||
|                             .font(.custom(Font.medium.rawValue, size: 14)) | ||||
|                             .foregroundColor(Color.gray77) | ||||
|                             .onTapGesture { | ||||
|                                 isModeModify = false | ||||
|                                 onClickDelete(commentItem.id) | ||||
|                                 isShowPopupMenu = false | ||||
|                             } | ||||
|   | ||||
| @@ -78,11 +78,11 @@ struct AudioContentCommentListView: View { | ||||
|                      | ||||
|                     HStack(spacing: 8) { | ||||
|                         KFImage(URL(string: UserDefaults.string(forKey: .profileImage))) | ||||
|                         .cancelOnDisappear(true) | ||||
|                         .downsampling(size: CGSize(width: 33.3, height: 33.3)) | ||||
|                         .resizable() | ||||
|                         .frame(width: 33.3, height: 33.3) | ||||
|                         .clipShape(Circle()) | ||||
|                             .cancelOnDisappear(true) | ||||
|                             .downsampling(size: CGSize(width: 33.3, height: 33.3)) | ||||
|                             .resizable() | ||||
|                             .frame(width: 33.3, height: 33.3) | ||||
|                             .clipShape(Circle()) | ||||
|                          | ||||
|                         HStack(spacing: 0) { | ||||
|                             TextField("댓글을 입력해 보세요.", text: $viewModel.comment) | ||||
| @@ -122,11 +122,11 @@ struct AudioContentCommentListView: View { | ||||
|                         .padding(.bottom, 13.3) | ||||
|                         .padding(.horizontal, 13.3) | ||||
|                      | ||||
|                     ScrollView(.vertical, showsIndicators: false) { | ||||
|                         LazyVStack(spacing: 13.3) { | ||||
|                             ForEach(0..<viewModel.commentList.count, id: \.self) { index in | ||||
|                                 let comment = viewModel.commentList[index] | ||||
|                                 VStack { | ||||
|                     if !viewModel.isRegisterComment { | ||||
|                         ScrollView(.vertical, showsIndicators: false) { | ||||
|                             LazyVStack(spacing: 13.3) { | ||||
|                                 ForEach(0..<viewModel.commentList.count, id: \.self) { index in | ||||
|                                     let comment = viewModel.commentList[index] | ||||
|                                     AudioContentCommentItemView( | ||||
|                                         contentCreatorId: creatorId, | ||||
|                                         audioContentId: audioContentId, | ||||
|   | ||||
| @@ -14,6 +14,7 @@ class AudioContentCommentListViewModel: ObservableObject { | ||||
|     private let repository = ContentRepository() | ||||
|     private var subscription = Set<AnyCancellable>() | ||||
|      | ||||
|     @Published var isRegisterComment = false | ||||
|     @Published var isLoading = false | ||||
|     @Published var errorMessage = "" | ||||
|     @Published var isShowPopup = false | ||||
| @@ -85,6 +86,7 @@ class AudioContentCommentListViewModel: ObservableObject { | ||||
|         } | ||||
|          | ||||
|         isLoading = true | ||||
|         isRegisterComment = true | ||||
|          | ||||
|         repository.registerComment(audioContentId: audioContentId, comment: comment, isSecret: isSecret) | ||||
|             .sink { result in | ||||
| @@ -96,6 +98,7 @@ class AudioContentCommentListViewModel: ObservableObject { | ||||
|                 } | ||||
|             } receiveValue: { [unowned self] response in | ||||
|                 self.isLoading = false | ||||
|                 self.isRegisterComment = false | ||||
|                 let responseData = response.data | ||||
|                  | ||||
|                 do { | ||||
| @@ -103,6 +106,7 @@ class AudioContentCommentListViewModel: ObservableObject { | ||||
|                     let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) | ||||
|                      | ||||
|                     if decoded.success { | ||||
|                         self.commentList.removeAll() | ||||
|                         self.comment = "" | ||||
|                         self.page = 1 | ||||
|                         self.isLast = false | ||||
|   | ||||
| @@ -110,35 +110,37 @@ struct AudioContentListReplyView: View { | ||||
|                     .padding(.horizontal, 26.7) | ||||
|                     .padding(.bottom, 13.3) | ||||
|                  | ||||
|                 ScrollView(.vertical, showsIndicators: false) { | ||||
|                     LazyVStack(spacing: 13.3) { | ||||
|                         ForEach(0..<viewModel.commentList.count, id: \.self) { index in | ||||
|                             let comment = viewModel.commentList[index] | ||||
|                             AudioContentCommentItemView( | ||||
|                                 contentCreatorId: creatorId, | ||||
|                                 audioContentId: audioContentId, | ||||
|                                 commentItem: comment, | ||||
|                                 isReplyComment: true, | ||||
|                                 isShowPopupMenuButton: true, | ||||
|                                 modifyComment: { commentId, comment in | ||||
|                                     hideKeyboard() | ||||
|                                     viewModel.modifyComment(commentId: commentId, audioContentId: audioContentId, comment: comment) | ||||
|                                 }, | ||||
|                                 onClickDelete: { | ||||
|                                     commentId = $0 | ||||
|                                     isShowDeletePopup = true | ||||
|                                 }, | ||||
|                                 onClickProfile: { | ||||
|                                     memberId = $0 | ||||
|                                     isShowMemberProfilePopup = true | ||||
|                                 } | ||||
|                             ) | ||||
|                 if !viewModel.isRegisterComment { | ||||
|                     ScrollView(.vertical, showsIndicators: false) { | ||||
|                         LazyVStack(spacing: 13.3) { | ||||
|                             ForEach(0..<viewModel.commentList.count, id: \.self) { index in | ||||
|                                 let comment = viewModel.commentList[index] | ||||
|                                 AudioContentCommentItemView( | ||||
|                                     contentCreatorId: creatorId, | ||||
|                                     audioContentId: audioContentId, | ||||
|                                     commentItem: comment, | ||||
|                                     isReplyComment: true, | ||||
|                                     isShowPopupMenuButton: true, | ||||
|                                     modifyComment: { commentId, comment in | ||||
|                                         hideKeyboard() | ||||
|                                         viewModel.modifyComment(commentId: commentId, audioContentId: audioContentId, comment: comment) | ||||
|                                     }, | ||||
|                                     onClickDelete: { | ||||
|                                         commentId = $0 | ||||
|                                         isShowDeletePopup = true | ||||
|                                     }, | ||||
|                                     onClickProfile: { | ||||
|                                         memberId = $0 | ||||
|                                         isShowMemberProfilePopup = true | ||||
|                                     } | ||||
|                                 ) | ||||
|                                 .padding(.horizontal, 40) | ||||
|                                 .onAppear { | ||||
|                                     if index == viewModel.commentList.count - 1 { | ||||
|                                         viewModel.getCommentList() | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -13,6 +13,7 @@ final class AudioContentListReplyViewModel: ObservableObject { | ||||
|     private let repository = ContentRepository() | ||||
|     private var subscription = Set<AnyCancellable>() | ||||
|      | ||||
|     @Published var isRegisterComment = false | ||||
|     @Published var isLoading = false | ||||
|     @Published var errorMessage = "" | ||||
|     @Published var isShowPopup = false | ||||
| @@ -83,6 +84,7 @@ final class AudioContentListReplyViewModel: ObservableObject { | ||||
|         } | ||||
|          | ||||
|         isLoading = true | ||||
|         isRegisterComment = true | ||||
|          | ||||
|         repository.registerComment(audioContentId: audioContentId, comment: comment, parentId: commentId) | ||||
|             .sink { result in | ||||
| @@ -94,6 +96,7 @@ final class AudioContentListReplyViewModel: ObservableObject { | ||||
|                 } | ||||
|             } receiveValue: { [unowned self] response in | ||||
|                 self.isLoading = false | ||||
|                 self.isRegisterComment = false | ||||
|                 let responseData = response.data | ||||
|                  | ||||
|                 do { | ||||
| @@ -101,6 +104,7 @@ final class AudioContentListReplyViewModel: ObservableObject { | ||||
|                     let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) | ||||
|                      | ||||
|                     if decoded.success { | ||||
|                         self.commentList.removeAll() | ||||
|                         self.comment = "" | ||||
|                         self.page = 1 | ||||
|                         self.isLast = false | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung