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-1211: Rewire current user email in AppEnvironment/AppDelegateViewModel #1966

Merged

Conversation

amy-at-kickstarter
Copy link
Contributor

📲 What

Fix AppEnvironment.current.currentUserEmail, which did not appear to be correctly saving the currently logged-in user's e-mail.

🤔 Why

We need the user's e-mail on the Thanks page for post-campaign backings. I noticed that we had this currentUserEmail property on Environment, but it wasn't working correctly. I did some digging and I figured it's because the signal is being deallocated before the value is set.

An interesting question is why currentUserEmail isn't just part of currentUser. Apparently the V1 User object doesn't appear to have an e-mail attached to it, and the e-mail is coming from GraphQL, instead. It's a bit messy but I wanted to keep this change fairly low-profile instead of doing more refactoring.

@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/MBL-1211/fix-current-user-email branch from 82b189b to 6ee9775 Compare March 4, 2024 23:21
@amy-at-kickstarter amy-at-kickstarter changed the title MBL-1211: Rewire current user email in AppEnvironment/AppDelegateViewMode MBL-1211: Rewire current user email in AppEnvironment/AppDelegateViewModel Mar 4, 2024
@@ -107,6 +107,7 @@ public struct AppEnvironment: AppEnvironmentType {
apiService: AppEnvironment.current.apiService.logout(),
cache: type(of: AppEnvironment.current.cache).init(),
currentUser: nil,
currentUserEmail: nil,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clear it on logout, too.

@amy-at-kickstarter amy-at-kickstarter marked this pull request as ready for review March 4, 2024 23:22
@amy-at-kickstarter amy-at-kickstarter self-assigned this Mar 4, 2024
@nativeksr
Copy link
Collaborator

SwiftFormat found issues:

File Rules
Library/AppEnvironment.swift:467:1 warning: (wrap) Wrap lines that exceed the specified maximum width.
Library/AppEnvironment.swift:468:1 warning: (wrap) Wrap lines that exceed the specified maximum width.
Library/AppEnvironment.swift:469:1 warning: (wrap) Wrap lines that exceed the specified maximum width.

Generated by 🚫 Danger


XCTAssertEqual(AppEnvironment.current.currentUserEmail, "nativesquad@ksr.com")

AppEnvironment.logout()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes this not-really-a-unit-test but I'm OK with the weirdness.

Copy link
Contributor

@scottkicks scottkicks left a comment

Choose a reason for hiding this comment

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

We should make note of this change for when we regression test the release since AppDelegate changes have a wide impact

@amy-at-kickstarter amy-at-kickstarter merged commit 261f4db into main Mar 5, 2024
5 checks passed
@amy-at-kickstarter amy-at-kickstarter deleted the feat/adyer/MBL-1211/fix-current-user-email branch March 5, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants