Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MBL-1036] Block User Popup + Banner Message #1880

Merged
merged 14 commits into from Nov 9, 2023
Merged

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Nov 6, 2023

📲 What

  1. Presents a confirmation alert when "Block this user" is selected from the block user action sheet
  2. Presents a success or fail Message Banner when tapping block in this new alert. This isn't wired up to an API or anything yet. This behavior is hardcoded for now.

🤔 Why

Rather than sending a blocking request from the action sheet, we're going to use this confirmation alert pattern so that we can provide extra information and double-check that they want to block a user.

🛠 How

The key areas are:

  • Comments
  • CommentReplies
  • ProjectPage
  • Messages

I'm taking advantage of the existing MessageBannerViewController that we use elsewhere in the app to display API response success and error banners. This means that each ViewController, except ProjectPage, needs to conform to MessageBannerViewControllerPresenting and present an instance of the banner when the corresponding ViewModel outputs a response from the API (which isn't wired up yet).

One caveat is that to keep users from spamming the block action sheet and alert, I'm disabling user interaction on the parent view until the success/error banner message is finished displaying. Once the success banner is dismissed on the project page, we auto-dismiss the view since the user doesn't want to see that content anymore. This could also set us up to more easily refresh our app content.

  • we won't dismiss when blocking from comments since users could block a user that doesn't own that project.

So basically I've:

  1. added functionality to display a new UIAlert when tapping the action sheet
  2. when tapping Block on this new alert, we trigger an input to the ViewModel (this will eventually kick off our backend request) and then a new userBlocked output notifies the ViewController of which banner to display. Success or error.

👀 See

🦋
Simulator Screen Recording - iPhone 15 Pro - 2023-11-07 at 10 44 02

✅ Acceptance criteria

Run the AppCenter Beta build. Make sure you're logged in and that the Block User FF is on.

  • Tapping the Block this user action sheet, from any of the key areas listed above, presents a UIAlert with an option to block or cancel
  • Tapping block user presents a banner message at the bottom of the screen. (this is temporarily controlled by a manual bool in the view model until we have an API to wire this up to)
  • If showing the success banner, the parent view is not tappable and dismisses once the banner hides
  • If showing the error banner, the parent view does not dismiss and users can try to again to block.

@scottkicks scottkicks self-assigned this Nov 6, 2023
@scottkicks scottkicks added this to the release-5.11.0 milestone Nov 6, 2023
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #1880 (06e3236) into main (67e4562) will decrease coverage by 0.07%.
The diff coverage is 15.20%.

@@            Coverage Diff             @@
##             main    #1880      +/-   ##
==========================================
- Coverage   83.83%   83.77%   -0.07%     
==========================================
  Files        1224     1224              
  Lines      111349   111457     +108     
  Branches    29601    29636      +35     
==========================================
+ Hits        93349    93368      +19     
- Misses      16989    17073      +84     
- Partials     1011     1016       +5     
Files Coverage Δ
Library/ViewModels/CommentRepliesViewModel.swift 98.24% <40.00%> (-1.76%) ⬇️
Library/ViewModels/CommentsViewModel.swift 98.57% <40.00%> (-0.85%) ⬇️
Library/ViewModels/MessagesViewModel.swift 94.78% <40.00%> (-2.50%) ⬇️
Library/ViewModels/ProjectPageViewModel.swift 96.21% <25.00%> (-0.78%) ⬇️
...anner/Controller/MessageBannerViewController.swift 67.44% <42.85%> (-1.92%) ⬇️
...nts/Controllers/CommentRepliesViewController.swift 54.05% <16.66%> (-3.41%) ⬇️
.../Comments/Controllers/CommentsViewController.swift 66.66% <16.66%> (-4.20%) ⬇️
...ectPage/Controller/ProjectPageViewController.swift 49.17% <15.78%> (-0.76%) ⬇️
...s/Messages/Controller/MessagesViewController.swift 0.00% <0.00%> (ø)
Library/UIAlertController.swift 0.64% <0.00%> (-0.06%) ⬇️

... and 1 file with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

…e the banner stretches to the width of its parent view
extension CommentRepliesViewController: MessageBannerViewControllerDelegate {
func messageBannerViewDidHide(type _: MessageBannerType) {
self.commentComposer.isHidden = false
self.view.isUserInteractionEnabled = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a peek in MessageBannerViewController, and it does already reference self.view.superview, so it might be safe to move isUserInteractionEnabled in there. But that's not a blocker, as previously discussed.

Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test on my machine, but 👀 code LGTM.

Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I added some nits that would be nice to fix before merging, but I don't think any of them are complicated enough that they'll require another review pass.

.showBanner(with: .success, message: "This user has been successfully blocked")
} else {
self?.messageBannerViewController?
.showBanner(with: .error, message: "Your request did not go through. Try again.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add a TODO here and for the other banner messages to update them once translated strings are ready

@@ -170,16 +189,26 @@ extension MessagesViewController: BackingCellDelegate {
// MARK: - MessageCellDelegate

extension MessagesViewController: MessageCellDelegate {
func messageCellDidTapHeader(_ cell: MessageCell, _: User) {
func messageCellDidTapHeader(_ cell: MessageCell, _ author: User) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think author is the right name in this context - just user would be better

@@ -99,6 +108,7 @@ public final class MessageBannerViewController: UIViewController, NibLoading {

if !isHidden {
self.view.superview?.bringSubviewToFront(self.view)
self.view.superview?.isUserInteractionEnabled = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want the message banner class to be responsible for turning on and off user interaction? I'm okay with that (as long as that works for all current call sites), but then the corresponding lines of code in the individual classes need to be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - It does work for the other call sites. Good catch. I thought I had gotten them all. Will remove it from the last 2 classes.

@scottkicks scottkicks merged commit 6abd404 into main Nov 9, 2023
7 checks passed
@scottkicks scottkicks deleted the scott/block-user-popup branch November 9, 2023 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants