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-1024] Wire Up Block User Mutation #1893

Merged
merged 11 commits into from Dec 4, 2023

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Nov 30, 2023

πŸ“² What

Now that the block mutation has been added, let's implement it.

πŸ€” Why

So we can block users!

πŸ›  How

We are letting users block someone from the following places:

  • Project Page
  • Message Threads
  • Comments & Comment Replies

When we call this mutation via AppEnvironment.current.apiService.blockUser... either an error will occur or it'll be successful. So, in each view model, I've set up an output for each case that will in turn present a success or error message banner.

We currently don't have the error messages that we can receive from the backend translated and localized so for now we are showing a generic "This didn't work" message. Not ideal. Showing a more useful message like, "You can only block someone that doesn't have a live project you have backed" would be better for obvious reasons so I think this should be a fast follow. Added a //TODO for this inline.

πŸ‘€ See

expects the same UI/UX that we've been working with up to now.

βœ… Acceptance criteria

  • We can block someone through each location listed above.

  • Attempting to block someone who has already been blocked will return an error

  • Attempting to block someone without internet will throw an error

  • The UI reflects newly blocked users

    • Info banner in message threads
    • Blocked user comments
    • Once the backend is finished projects by blocked users will be filtered out, so there is no UI to inform you of this directly on a project page.
  • you can also double-check that someone has been blocked successfully here https://staging.kickstarter.com/graphiql

⏰ TODO

  • Waiting on the id vs uid change to be made on prod. Once that's updated we can test that the app reloads after blocking and filters out blocked content correctly
  • Add VM tests

@scottkicks scottkicks self-assigned this Nov 30, 2023
@scottkicks scottkicks added this to the release-5.11.0 milestone Nov 30, 2023
@scottkicks scottkicks marked this pull request as ready for review December 3, 2023 19:06
.switchMap { input in
AppEnvironment.current.apiService
.blockUser(input: input)
.ksr_delay(AppEnvironment.current.apiDelayInterval, on: AppEnvironment.current.scheduler)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for my own edition, what's up with ksr_delay everywhere when we make network requests?

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.

On the whole, LGTM. Left a few questions that may or may not need to be addressed.

Will you be adding tests for the view models? I'm fine with that as a follow-on PR but seems like it would be good to double-check that all of the plumbing is working correctly.

@scottkicks
Copy link
Contributor Author

@amy-at-kickstarter Thanks - yea, I have add tests on my to-do list in the description above. I wanted to jump-start the review while I do those.

@scottkicks scottkicks force-pushed the mbl-1024-wire-up-blocking-mutation branch from 0e58684 to 0880bce Compare December 4, 2023 16:16
@kickstarter kickstarter deleted a comment from codecov bot Dec 4, 2023
@kickstarter kickstarter deleted a comment from nativeksr Dec 4, 2023
@kickstarter kickstarter deleted a comment from codecov bot Dec 4, 2023
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: 56 lines in your changes are missing coverage. Please review.

Comparison is base (85a4d86) 83.70% compared to head (0880bce) 83.74%.

Files Patch % Lines
...s/Messages/Controller/MessagesViewController.swift 0.00% 13 Missing ⚠️
...ectPage/Controller/ProjectPageViewController.swift 18.75% 13 Missing ⚠️
...nts/Controllers/CommentRepliesViewController.swift 20.00% 12 Missing ⚠️
.../Comments/Controllers/CommentsViewController.swift 20.00% 12 Missing ⚠️
KsApi/MockService.swift 14.28% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1893      +/-   ##
==========================================
+ Coverage   83.70%   83.74%   +0.03%     
==========================================
  Files        1225     1226       +1     
  Lines      111585   111767     +182     
  Branches    29687    29725      +38     
==========================================
+ Hits        93402    93598     +196     
+ Misses      17161    17152       -9     
+ Partials     1022     1017       -5     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@@ -108,6 +111,67 @@ internal final class CommentRepliesViewModelTests: TestCase {
}
}

func testDidBlockUser_EmitsOnSuccess() {
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ‘

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.

Just skimmed but tests LGTM as well.

One thing I'm thinking about in the back of my head - blocking functionality is pretty much identical in the three view models we implement it in. Do we have a pattern for sharing code between view models? (This isn't blocking feedback for this change, but I'm curious if there's a cleaner pattern.)

@scottkicks
Copy link
Contributor Author

Do we have a pattern for sharing code between view models?

It's a good callout. We could create a BlockUser service that can be injected and used across the app. I opted to stick with what's more common in the app currently because this is more time-sensitive, but I think it could be cleaner.

@scottkicks scottkicks merged commit 6886cab into main Dec 4, 2023
7 checks passed
@scottkicks scottkicks deleted the mbl-1024-wire-up-blocking-mutation branch December 4, 2023 19:19
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

2 participants