@@ -2,6 +2,11 @@ import Foundation
22import UIKit
33import WordPressShared
44
5+ // Notification sent when a comment is moderated/edited to allow views that display Comments to update if necessary.
6+ // Specifically, the Comments snippet on ReaderDetailViewController.
7+ extension NSNotification . Name {
8+ static let ReaderCommentModifiedNotification = NSNotification . Name ( rawValue: " ReaderCommentModifiedNotification " )
9+ }
510
611@objc public extension ReaderCommentsViewController {
712 func shouldShowSuggestions( for siteID: NSNumber ? ) -> Bool {
@@ -218,6 +223,8 @@ private extension ReaderCommentsViewController {
218223 CommentAnalytics . trackCommentEdited ( comment: comment)
219224
220225 self ? . commentService. uploadComment ( comment, success: {
226+ NotificationCenter . default. post ( name: . ReaderCommentModifiedNotification, object: nil )
227+
221228 // update the thread again in case the approval status changed.
222229 tableView. reloadRows ( at: [ indexPath] , with: . automatic)
223230 } , failure: { _ in
@@ -232,6 +239,8 @@ private extension ReaderCommentsViewController {
232239
233240 func moderateComment( _ comment: Comment , status: CommentStatusType , handler: WPTableViewHandler ) {
234241 let successBlock : ( String ) -> Void = { [ weak self] noticeText in
242+ NotificationCenter . default. post ( name: . ReaderCommentModifiedNotification, object: nil )
243+
235244 // Adjust the ReaderPost's comment count.
236245 if let post = self ? . post, let commentCount = post. commentCount? . intValue {
237246 let adjustment = ( status == . approved) ? 1 : - 1
0 commit comments