Skip to content

Commit 6a1f355

Browse files
authored
Remove more dead code (#24183)
* Remove NoteBlockActionsTableViewCell * Remove VerticallyStackedButton * Remove remaining action-related code
1 parent d1799c5 commit 6a1f355

6 files changed

+0
-754
lines changed

WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationDetailsViewController.swift

-195
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ extension NotificationDetailsViewController {
358358
let cellClassNames: [NoteBlockTableViewCell.Type] = [
359359
NoteBlockHeaderTableViewCell.self,
360360
NoteBlockTextTableViewCell.self,
361-
NoteBlockActionsTableViewCell.self,
362361
NoteBlockCommentTableViewCell.self,
363362
NoteBlockImageTableViewCell.self,
364363
NoteBlockUserTableViewCell.self,
@@ -482,8 +481,6 @@ private extension NotificationDetailsViewController {
482481
return NoteBlockTextTableViewCell.reuseIdentifier()
483482
case .comment:
484483
return NoteBlockCommentTableViewCell.reuseIdentifier()
485-
case .actions:
486-
return NoteBlockActionsTableViewCell.reuseIdentifier()
487484
case .image:
488485
return NoteBlockImageTableViewCell.reuseIdentifier()
489486
case .user:
@@ -517,8 +514,6 @@ private extension NotificationDetailsViewController {
517514
setupUserCell(cell, blockGroup: blockGroup)
518515
case let cell as NoteBlockCommentTableViewCell:
519516
setupCommentCell(cell, blockGroup: blockGroup, at: indexPath)
520-
case let cell as NoteBlockActionsTableViewCell:
521-
setupActionsCell(cell, blockGroup: blockGroup)
522517
case let cell as NoteBlockImageTableViewCell:
523518
setupImageCell(cell, blockGroup: blockGroup)
524519
case let cell as NoteBlockTextTableViewCell:
@@ -662,58 +657,6 @@ private extension NotificationDetailsViewController {
662657
cell.downloadGravatarWithURL(mediaURL)
663658
}
664659

665-
func setupActionsCell(_ cell: NoteBlockActionsTableViewCell, blockGroup: FormattableContentGroup) {
666-
guard let commentBlock: FormattableCommentContent = blockGroup.blockOfKind(.comment) else {
667-
assertionFailure("Missing Comment Block for Notification \(note.notificationId)")
668-
return
669-
}
670-
671-
// Setup: Properties
672-
// Note: Approve Action is actually a synonym for 'Edit' (Based on Calypso's basecode)
673-
//
674-
cell.isReplyEnabled = UIDevice.isPad() && commentBlock.isActionOn(id: ReplyToCommentAction.actionIdentifier())
675-
cell.isLikeEnabled = commentBlock.isActionEnabled(id: LikeCommentAction.actionIdentifier())
676-
cell.isApproveEnabled = commentBlock.isActionEnabled(id: ApproveCommentAction.actionIdentifier())
677-
cell.isTrashEnabled = commentBlock.isActionEnabled(id: TrashCommentAction.actionIdentifier())
678-
cell.isSpamEnabled = commentBlock.isActionEnabled(id: MarkAsSpamAction.actionIdentifier())
679-
cell.isEditEnabled = commentBlock.isActionOn(id: ApproveCommentAction.actionIdentifier())
680-
cell.isLikeOn = commentBlock.isActionOn(id: LikeCommentAction.actionIdentifier())
681-
cell.isApproveOn = commentBlock.isActionOn(id: ApproveCommentAction.actionIdentifier())
682-
683-
// Setup: Callbacks
684-
cell.onReplyClick = { _ in
685-
wpAssertionFailure("no longer used")
686-
}
687-
688-
cell.onLikeClick = { [weak self] _ in
689-
self?.likeCommentWithBlock(commentBlock)
690-
}
691-
692-
cell.onUnlikeClick = { [weak self] _ in
693-
self?.unlikeCommentWithBlock(commentBlock)
694-
}
695-
696-
cell.onApproveClick = { [weak self] _ in
697-
self?.approveCommentWithBlock(commentBlock)
698-
}
699-
700-
cell.onUnapproveClick = { [weak self] _ in
701-
self?.unapproveCommentWithBlock(commentBlock)
702-
}
703-
704-
cell.onTrashClick = { [weak self] _ in
705-
self?.trashCommentWithBlock(commentBlock)
706-
}
707-
708-
cell.onSpamClick = { [weak self] _ in
709-
self?.spamCommentWithBlock(commentBlock)
710-
}
711-
712-
cell.onEditClick = { [weak self] _ in
713-
wpAssertionFailure("unused")
714-
}
715-
}
716-
717660
func setupImageCell(_ cell: NoteBlockImageTableViewCell, blockGroup: FormattableContentGroup) {
718661
guard let imageBlock = blockGroup.blocks.first as? NotificationTextContent else {
719662
assertionFailure("Missing Image Block for Notification [\(note.notificationId)")
@@ -912,144 +855,6 @@ private extension NotificationDetailsViewController {
912855
actionsService.unfollowSiteWithBlock(block)
913856
WPAppAnalytics.track(.notificationsSiteUnfollowAction, withBlogID: block.metaSiteID)
914857
}
915-
916-
func likeCommentWithBlock(_ block: FormattableCommentContent) {
917-
guard let likeAction = block.action(id: LikeCommentAction.actionIdentifier()) else {
918-
return
919-
}
920-
let actionContext = ActionContext(block: block)
921-
likeAction.execute(context: actionContext)
922-
WPAppAnalytics.track(.notificationsCommentLiked, withBlogID: block.metaSiteID)
923-
}
924-
925-
func unlikeCommentWithBlock(_ block: FormattableCommentContent) {
926-
guard let likeAction = block.action(id: LikeCommentAction.actionIdentifier()) else {
927-
return
928-
}
929-
let actionContext = ActionContext(block: block)
930-
likeAction.execute(context: actionContext)
931-
WPAppAnalytics.track(.notificationsCommentUnliked, withBlogID: block.metaSiteID)
932-
}
933-
934-
func approveCommentWithBlock(_ block: FormattableCommentContent) {
935-
guard let approveAction = block.action(id: ApproveCommentAction.actionIdentifier()) else {
936-
return
937-
}
938-
939-
let actionContext = ActionContext(block: block)
940-
approveAction.execute(context: actionContext)
941-
WPAppAnalytics.track(.notificationsCommentApproved, withBlogID: block.metaSiteID)
942-
}
943-
944-
func unapproveCommentWithBlock(_ block: FormattableCommentContent) {
945-
guard let approveAction = block.action(id: ApproveCommentAction.actionIdentifier()) else {
946-
return
947-
}
948-
949-
let actionContext = ActionContext(block: block)
950-
approveAction.execute(context: actionContext)
951-
WPAppAnalytics.track(.notificationsCommentUnapproved, withBlogID: block.metaSiteID)
952-
}
953-
954-
func spamCommentWithBlock(_ block: FormattableCommentContent) {
955-
guard onDeletionRequestCallback != nil else {
956-
// callback probably missing due to state restoration. at least by
957-
// not crashing the user can tap the back button and try again
958-
return
959-
}
960-
961-
guard let spamAction = block.action(id: MarkAsSpamAction.actionIdentifier()) else {
962-
return
963-
}
964-
965-
let actionContext = ActionContext(block: block, completion: { [weak self] (request, success) in
966-
WPAppAnalytics.track(.notificationsCommentFlaggedAsSpam, withBlogID: block.metaSiteID)
967-
guard let request else {
968-
return
969-
}
970-
self?.onDeletionRequestCallback?(request)
971-
})
972-
973-
spamAction.execute(context: actionContext)
974-
975-
// We're thru
976-
_ = navigationController?.popToRootViewController(animated: true)
977-
}
978-
979-
func trashCommentWithBlock(_ block: FormattableCommentContent) {
980-
guard onDeletionRequestCallback != nil else {
981-
// callback probably missing due to state restoration. at least by
982-
// not crashing the user can tap the back button and try again
983-
return
984-
}
985-
986-
guard let trashAction = block.action(id: TrashCommentAction.actionIdentifier()) else {
987-
return
988-
}
989-
990-
let actionContext = ActionContext(block: block, completion: { [weak self] (request, success) in
991-
WPAppAnalytics.track(.notificationsCommentTrashed, withBlogID: block.metaSiteID)
992-
guard let request else {
993-
return
994-
}
995-
self?.onDeletionRequestCallback?(request)
996-
})
997-
998-
trashAction.execute(context: actionContext)
999-
1000-
// We're thru
1001-
_ = navigationController?.popToRootViewController(animated: true)
1002-
}
1003-
1004-
func updateCommentWithBlock(_ block: FormattableCommentContent, content: String) {
1005-
guard let editCommentAction = block.action(id: EditCommentAction.actionIdentifier()) else {
1006-
return
1007-
}
1008-
1009-
let generator = UINotificationFeedbackGenerator()
1010-
generator.prepare()
1011-
generator.notificationOccurred(.success)
1012-
1013-
let actionContext = ActionContext(block: block, content: content) { [weak self] (request, success) in
1014-
guard success == false else {
1015-
CommentAnalytics.trackCommentEdited(block: block)
1016-
return
1017-
}
1018-
1019-
generator.notificationOccurred(.error)
1020-
self?.displayCommentUpdateErrorWithBlock(block, content: content)
1021-
}
1022-
1023-
editCommentAction.execute(context: actionContext)
1024-
}
1025-
}
1026-
1027-
// MARK: - Editing Comments
1028-
//
1029-
private extension NotificationDetailsViewController {
1030-
1031-
func updateComment(with commentContent: FormattableCommentContent, content: String) {
1032-
self.updateCommentWithBlock(commentContent, content: content)
1033-
}
1034-
1035-
func displayCommentUpdateErrorWithBlock(_ block: FormattableCommentContent, content: String) {
1036-
let message = NSLocalizedString("There has been an unexpected error while updating your comment",
1037-
comment: "Displayed whenever a Comment Update Fails")
1038-
let cancelTitle = NSLocalizedString("Give Up", comment: "Cancel")
1039-
let retryTitle = NSLocalizedString("Try Again", comment: "Retry")
1040-
1041-
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
1042-
alertController.addCancelActionWithTitle(cancelTitle) { action in
1043-
block.textOverride = nil
1044-
self.refreshInterface()
1045-
}
1046-
alertController.addDefaultActionWithTitle(retryTitle) { action in
1047-
self.updateComment(with: block, content: content)
1048-
}
1049-
1050-
// Note: This viewController might not be visible anymore
1051-
alertController.presentFromRootViewController()
1052-
}
1053858
}
1054859

1055860
// MARK: - Milestone notifications

WordPress/Classes/ViewRelated/Notifications/Style/WPStyleGuide+Notifications.swift

-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ extension WPStyleGuide {
190190
.foregroundColor: blockNoticonColor ]
191191
}
192192

193-
// Action Buttons
194-
public static let blockActionDisabledColor = UIColor.secondaryLabel
195-
public static let blockActionEnabledColor = UIAppColor.primary
196-
197193
// RichText Helpers
198194
public static func blockBackgroundColorForRichText(_ isBadge: Bool) -> UIColor {
199195
return isBadge ? badgeBackgroundColor : blockBackgroundColor

0 commit comments

Comments
 (0)