@@ -48,10 +48,6 @@ class NotificationDetailsViewController: UIViewController, NoResultsViewHost {
48
48
///
49
49
@IBOutlet var badgeCenterLayoutConstraint : NSLayoutConstraint !
50
50
51
- /// RelpyTextView
52
- ///
53
- @IBOutlet var replyTextView : CommentLargeButton !
54
-
55
51
/// Embedded Media Downloader
56
52
///
57
53
fileprivate var mediaDownloader = NotificationMediaDownloader ( )
@@ -139,7 +135,6 @@ class NotificationDetailsViewController: UIViewController, NoResultsViewHost {
139
135
setupTableView ( )
140
136
setupTableViewCells ( )
141
137
setupTableDelegates ( )
142
- setupReplyTextView ( )
143
138
}
144
139
145
140
override func viewWillAppear( _ animated: Bool ) {
@@ -201,7 +196,6 @@ class NotificationDetailsViewController: UIViewController, NoResultsViewHost {
201
196
fileprivate func refreshInterface( ) {
202
197
formatter. resetCache ( )
203
198
tableView. reloadData ( )
204
- attachReplyViewIfNeeded ( )
205
199
adjustLayoutConstraintsIfNeeded ( )
206
200
refreshNavigationBar ( )
207
201
}
@@ -358,7 +352,6 @@ extension NotificationDetailsViewController {
358
352
let cellClassNames : [ NoteBlockTableViewCell . Type ] = [
359
353
NoteBlockHeaderTableViewCell . self,
360
354
NoteBlockTextTableViewCell . self,
361
- NoteBlockCommentTableViewCell . self,
362
355
NoteBlockImageTableViewCell . self,
363
356
NoteBlockUserTableViewCell . self,
364
357
NoteBlockButtonTableViewCell . self
@@ -395,22 +388,6 @@ extension NotificationDetailsViewController {
395
388
}
396
389
}
397
390
398
- func setupReplyTextView( ) {
399
- let replyTextView = CommentLargeButton ( )
400
-
401
- replyTextView. placeholder = NSLocalizedString ( " Write a reply " , comment: " Placeholder text for inline compose view " )
402
- replyTextView. accessibilityLabel = NSLocalizedString ( " Reply Text " , comment: " Notifications Reply Accessibility Identifier " )
403
-
404
- replyTextView. onTap = {
405
- // TODO: (kean) remove the remaining .comment-related code
406
- wpAssertionFailure ( " Notifications have been using NotificationCommentDetailViewController since 2023 " )
407
- }
408
-
409
- replyTextView. setContentCompressionResistancePriority ( . required, for: . vertical)
410
-
411
- self . replyTextView = replyTextView
412
- }
413
-
414
391
func setupNotificationListeners( ) {
415
392
let nc = NotificationCenter . default
416
393
nc. addObserver ( self , selector: #selector( notificationWasUpdated) , name: . NSManagedObjectContextObjectsDidChange, object: note. managedObjectContext)
@@ -422,28 +399,6 @@ extension NotificationDetailsViewController {
422
399
}
423
400
}
424
401
425
- // MARK: - Reply View Helpers
426
- //
427
- extension NotificationDetailsViewController {
428
- func attachReplyViewIfNeeded( ) {
429
- guard shouldAttachReplyView else {
430
- replyTextView. removeFromSuperview ( )
431
- return
432
- }
433
-
434
- stackView. addArrangedSubview ( replyTextView)
435
- }
436
-
437
- var shouldAttachReplyView : Bool {
438
- // Attach the Reply component only if the notification has a comment, and it can be replied to.
439
- //
440
- guard let block: FormattableCommentContent = note. contentGroup ( ofKind: . comment) ? . blockOfKind ( . comment) else {
441
- return false
442
- }
443
- return block. action ( id: ReplyToCommentAction . actionIdentifier ( ) ) ? . on ?? false
444
- }
445
- }
446
-
447
402
// MARK: - Layout Helpers
448
403
//
449
404
private extension NotificationDetailsViewController {
@@ -479,16 +434,14 @@ private extension NotificationDetailsViewController {
479
434
fallthrough
480
435
case . text:
481
436
return NoteBlockTextTableViewCell . reuseIdentifier ( )
482
- case . comment:
483
- return NoteBlockCommentTableViewCell . reuseIdentifier ( )
484
437
case . image:
485
438
return NoteBlockImageTableViewCell . reuseIdentifier ( )
486
439
case . user:
487
440
return NoteBlockUserTableViewCell . reuseIdentifier ( )
488
441
case . button:
489
442
return NoteBlockButtonTableViewCell . reuseIdentifier ( )
490
443
default :
491
- assertionFailure ( " Unmanaged group kind: \( blockGroup. kind) " )
444
+ wpAssertionFailure ( " Unmanaged group kind " , userInfo : [ " kind " : " \( blockGroup. kind) " ] )
492
445
return NoteBlockTextTableViewCell . reuseIdentifier ( )
493
446
}
494
447
}
@@ -512,8 +465,6 @@ private extension NotificationDetailsViewController {
512
465
setupFooterCell ( cell, blockGroup: blockGroup)
513
466
case let cell as NoteBlockUserTableViewCell :
514
467
setupUserCell ( cell, blockGroup: blockGroup)
515
- case let cell as NoteBlockCommentTableViewCell :
516
- setupCommentCell ( cell, blockGroup: blockGroup, at: indexPath)
517
468
case let cell as NoteBlockImageTableViewCell :
518
469
setupImageCell ( cell, blockGroup: blockGroup)
519
470
case let cell as NoteBlockTextTableViewCell :
@@ -587,76 +538,6 @@ private extension NotificationDetailsViewController {
587
538
cell. downloadGravatarWithURL ( mediaURL)
588
539
}
589
540
590
- func setupCommentCell( _ cell: NoteBlockCommentTableViewCell , blockGroup: FormattableContentGroup , at indexPath: IndexPath ) {
591
- // Note:
592
- // The main reason why it's a very good idea *not* to reuse NoteBlockHeaderTableViewCell, just to display the
593
- // gravatar, is because we're implementing a custom behavior whenever the user approves/ unapproves the comment.
594
- //
595
- // - Font colors are updated.
596
- // - A left separator is displayed.
597
- //
598
- guard let commentBlock: FormattableCommentContent = blockGroup. blockOfKind ( . comment) else {
599
- assertionFailure ( " Missing Comment Block for Notification [ \( note. notificationId) ] " )
600
- return
601
- }
602
-
603
- guard let userBlock: FormattableUserContent = blockGroup. blockOfKind ( . user) else {
604
- assertionFailure ( " Missing User Block for Notification [ \( note. notificationId) ] " )
605
- return
606
- }
607
-
608
- // Merge the Attachments with their ranges: [NSRange: UIImage]
609
- let mediaMap = mediaDownloader. imagesForUrls ( commentBlock. imageUrls)
610
- let mediaRanges = commentBlock. buildRangesToImagesMap ( mediaMap)
611
-
612
- let styles = RichTextContentStyles ( key: " RichText- \( indexPath) " )
613
- let text = formatter. render ( content: commentBlock, with: styles) . stringByEmbeddingImageAttachments ( mediaRanges)
614
-
615
- // Setup: Properties
616
- cell. name = userBlock. text
617
- cell. timestamp = ( note. timestampAsDate as NSDate ) . mediumString ( )
618
- cell. site = userBlock. metaTitlesHome ?? userBlock. metaLinksHome? . host
619
- cell. attributedCommentText = text. trimNewlines ( )
620
- cell. isApproved = commentBlock. isCommentApproved
621
-
622
- // Add comment author's name to Reply placeholder.
623
- let placeholderFormat = NSLocalizedString ( " Reply to %1$@ " ,
624
- comment: " Placeholder text for replying to a comment. %1$@ is a placeholder for the comment author's name. " )
625
- replyTextView. placeholder = String ( format: placeholderFormat, cell. name ?? String ( ) )
626
-
627
- // Setup: Callbacks
628
- cell. onUserClick = { [ weak self] in
629
- guard let homeURL = userBlock. metaLinksHome else {
630
- return
631
- }
632
-
633
- self ? . displayURL ( homeURL)
634
- }
635
-
636
- cell. onUrlClick = { [ weak self] url in
637
- self ? . displayURL ( url as URL )
638
- }
639
-
640
- cell. onAttachmentClick = { [ weak self] attachment in
641
- guard let image = attachment. image else {
642
- return
643
- }
644
- self ? . router. routeTo ( image)
645
- }
646
-
647
- cell. onTimeStampLongPress = { [ weak self] in
648
- guard let urlString = self ? . note. url,
649
- let url = URL ( string: urlString) else {
650
- return
651
- }
652
- UIAlertController . presentAlertAndCopyCommentURLToClipboard ( url: url)
653
- }
654
-
655
- // Download the Gravatar
656
- let mediaURL = userBlock. media. first? . mediaURL
657
- cell. downloadGravatarWithURL ( mediaURL)
658
- }
659
-
660
541
func setupImageCell( _ cell: NoteBlockImageTableViewCell , blockGroup: FormattableContentGroup ) {
661
542
guard let imageBlock = blockGroup. blocks. first as? NotificationTextContent else {
662
543
assertionFailure ( " Missing Image Block for Notification [ \( note. notificationId) " )
@@ -974,19 +855,19 @@ private extension NotificationDetailsViewController {
974
855
}
975
856
976
857
enum ContentMedia {
977
- static let richBlockTypes = Set ( arrayLiteral: FormattableContentKind . text, FormattableContentKind . comment)
978
- static let duration = TimeInterval ( 0.25 )
979
- static let delay = TimeInterval ( 0 )
858
+ static let richBlockTypes = Set ( arrayLiteral: FormattableContentKind . text, FormattableContentKind . comment)
859
+ static let duration = TimeInterval ( 0.25 )
860
+ static let delay = TimeInterval ( 0 )
980
861
static let options : UIView . AnimationOptions = [ . overrideInheritedDuration, . beginFromCurrentState]
981
862
}
982
863
983
864
enum Settings {
984
- static let numberOfSections = 1
985
- static let estimatedRowHeight = CGFloat ( 44 )
865
+ static let numberOfSections = 1
866
+ static let estimatedRowHeight = CGFloat ( 44 )
986
867
}
987
868
988
869
enum Assets {
989
- static let confettiBackground = " notifications-confetti-background "
870
+ static let confettiBackground = " notifications-confetti-background "
990
871
}
991
872
}
992
873
@@ -1003,5 +884,4 @@ extension NotificationDetailsViewController {
1003
884
//
1004
885
private extension String {
1005
886
static let notificationDetailsTableAccessibilityId = " notifications-details-table "
1006
- static let replyTextViewAccessibilityId = " reply-text-view "
1007
887
}
0 commit comments