Skip to content

Commit

Permalink
Merge pull request #17433 from wordpress-mobile/feature/17412-create_…
Browse files Browse the repository at this point in the history
…reply

Comment Reply: create comment reply.
  • Loading branch information
ScoutHarris authored Nov 8, 2021
2 parents 7cd1251 + 364c41e commit 9004f98
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,26 @@ private extension CommentDetailViewController {
}

@objc func createReply(content: String) {
// TODO: create reply
CommentAnalytics.trackCommentRepliedTo(comment: comment)

guard let reply = commentService.createReply(for: comment) else {
DDLogError("Failed creating comment reply.")
return
}

reply.content = content

commentService.uploadComment(reply, success: { [weak self] in
self?.displayReplyNotice(success: true)
self?.refreshCommentReplyIfNeeded()
}, failure: { [weak self] error in
self?.displayReplyNotice(success: false)
})
}

func displayReplyNotice(success: Bool) {
let message = success ? ReplyMessages.successMessage : ReplyMessages.failureMessage
displayNotice(title: message)
}

func configureSuggestionsView() {
Expand Down Expand Up @@ -922,6 +941,11 @@ private extension CommentDetailViewController {
return SuggestionService.shared.shouldShowSuggestions(for: blog)
}

struct ReplyMessages {
static let successMessage = NSLocalizedString("Reply Sent!", comment: "The app successfully sent a comment")
static let failureMessage = NSLocalizedString("There has been an unexpected error while sending your reply", comment: "Reply Failure Message")
}

}

// MARK: - ReplyTextViewDelegate
Expand Down

0 comments on commit 9004f98

Please sign in to comment.