Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CommentViewController
- func sendSubComment() {
- if let text = textView.text,
- let username = self.username,
- let user_picture = profile?.picture,
- let user_id = profile?.sub,
- let parent_id = parent_id {
- let comment = Comment(post_id: "2d44a588-e47a-43c5-bd16-94e7073e4e14", username: username, user_picture: user_picture.absoluteString, user_id: user_id, text: text, parent_id: parent_id)
- let postRequest = CommentPostRequest(endpoint: "sub_comment")
- postRequest.save(comment) { (result) in
- switch result {
- case .success(let comment):
- self.delegate2?.didSendSubComment()
- case .failure(let error):
- print("An error occurred: \(error)")
- }
- }
- }
- }
- //CommentCell
- extension CommentCell: TableViewDelegate {
- func didSendSubComment() {
- if let id = parent_id {
- viewModel?.loadSubCommentsAfterReply(comment_id: id)
- }
- }
- }
- //CommentViewModel
- func loadSubCommentsAfterReply(comment_id:String?) {
- if let id = comment_id {
- let getSubComments = GETSubComments(id: id, path: "subComments", offset: "0")
- getSubComments.getAllById {
- self.subComments += $0
- self.subCommentDidInserts?($0)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement