Skip to content

Commit

Permalink
dismiss comment and message viewcontrollers on successful blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
scottkicks committed Nov 7, 2023
1 parent 1977b86 commit 1d303f8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ final class CommentRepliesViewController: UITableViewController, MessageBannerVi
if success {
self?.messageBannerViewController?
.showBanner(with: .success, message: "This user has been successfully blocked")
self?.view.isUserInteractionEnabled = false

Check warning on line 181 in Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift#L179-L181

Added lines #L179 - L181 were not covered by tests
} else {
self?.messageBannerViewController?
.showBanner(with: .error, message: "Your request did not go through. Try again.")

Check warning on line 184 in Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift#L183-L184

Added lines #L183 - L184 were not covered by tests
Expand Down Expand Up @@ -260,8 +261,12 @@ extension CommentRepliesViewController: RootCommentCellDelegate {
// MARK: - MessageBannerViewControllerDelegate

extension CommentRepliesViewController: MessageBannerViewControllerDelegate {
func messageBannerViewDidHide(type _: MessageBannerType) {
func messageBannerViewDidHide(type: MessageBannerType) {
self.commentComposer.isHidden = false

Check warning on line 265 in Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift#L265

Added line #L265 was not covered by tests

if type == .success {
self.dismiss(animated: true)

Check warning on line 268 in Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentRepliesViewController.swift#L268

Added line #L268 was not covered by tests
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ internal final class CommentsViewController: UITableViewController, MessageBanne
if success {
self?.messageBannerViewController?
.showBanner(with: .success, message: "This user has been successfully blocked")
self?.view.isUserInteractionEnabled = false

Check warning on line 199 in Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift#L197-L199

Added lines #L197 - L199 were not covered by tests
} else {
self?.messageBannerViewController?
.showBanner(with: .error, message: "Your request did not go through. Try again.")

Check warning on line 202 in Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift#L201-L202

Added lines #L201 - L202 were not covered by tests
Expand Down Expand Up @@ -300,8 +301,12 @@ extension CommentsViewController: CommentRemovedCellDelegate {
// MARK: - MessageBannerViewControllerDelegate

extension CommentsViewController: MessageBannerViewControllerDelegate {
func messageBannerViewDidHide(type _: MessageBannerType) {
func messageBannerViewDidHide(type: MessageBannerType) {
self.commentComposer.isHidden = false

Check warning on line 305 in Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift#L305

Added line #L305 was not covered by tests

if type == .success {
self.dismiss(animated: true)

Check warning on line 308 in Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Comments/Controllers/CommentsViewController.swift#L308

Added line #L308 was not covered by tests
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal final class MessagesViewController: UITableViewController, MessageBanne
super.viewDidLoad()

self.messageBannerViewController = self.configureMessageBannerViewController(on: self)
self.messageBannerViewController?.delegate = self

Check warning on line 34 in Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift#L33-L34

Added lines #L33 - L34 were not covered by tests
self.tableView.rowHeight = UITableView.automaticDimension
self.tableView.dataSource = self.dataSource

Expand Down Expand Up @@ -100,9 +101,11 @@ internal final class MessagesViewController: UITableViewController, MessageBanne
self.viewModel.outputs.userBlocked
.observeForUI()

Check warning on line 102 in Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift#L101-L102

Added lines #L101 - L102 were not covered by tests
.observeValues { [weak self] success in

if success {
self?.messageBannerViewController?
.showBanner(with: .success, message: "This user has been successfully blocked")
self?.view.isUserInteractionEnabled = false

Check warning on line 108 in Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift#L106-L108

Added lines #L106 - L108 were not covered by tests
} else {
self?.messageBannerViewController?
.showBanner(with: .error, message: "Your request did not go through. Try again.")

Check warning on line 111 in Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift#L110-L111

Added lines #L110 - L111 were not covered by tests
Expand Down Expand Up @@ -206,3 +209,13 @@ extension MessagesViewController: MessageCellDelegate {
self.present(actionSheet, animated: true)
}
}

// MARK: - MessageBannerViewControllerDelegate

extension MessagesViewController: MessageBannerViewControllerDelegate {
func messageBannerViewDidHide(type: MessageBannerType) {
if type == .success {
self.navigationController?.popViewController(animated: true)

Check warning on line 218 in Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/Messages/Controller/MessagesViewController.swift#L218

Added line #L218 was not covered by tests
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,11 @@ public final class ProjectPageViewController: UIViewController, MessageBannerVie
if success {
self?.messageBannerViewController?
.showBanner(with: .success, message: "This user has been successfully blocked")
self?.view.isUserInteractionEnabled = false

Check warning on line 546 in Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift#L544-L546

Added lines #L544 - L546 were not covered by tests
} else {
self?.messageBannerViewController?
.showBanner(with: .error, message: "Your request did not go through. Try again.")

Check warning on line 549 in Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift

View check run for this annotation

Codecov / codecov/patch

Kickstarter-iOS/Features/ProjectPage/Controller/ProjectPageViewController.swift#L548-L549

Added lines #L548 - L549 were not covered by tests
}

self?.view.isUserInteractionEnabled = false
}
}

Expand Down

0 comments on commit 1d303f8

Please sign in to comment.