StanfordSpezi / SpeziAccount

The Spezi Account module to enable login and signup functionality
https://swiftpackageindex.com/StanfordSpezi/SpeziAccount/documentation/
MIT License
6 stars 5 forks source link

Allow AccountSetup to be created with async function to handle completeness of the account setup #73

Closed pauljohanneskraft closed 3 weeks ago

pauljohanneskraft commented 2 months ago

Allow AccountSetup to be created with async throwing function to handle completeness of the account setup

:recycle: Current situation & Problem

When an account setup is successful, one may want to run additional code that is async and throwing to finish the account setup completely.

Specifically in ENGAGE-HF, we need to call a Firebase function when a new account has been created before the account can actually be used.

:gear: Release Notes

:books: Documentation

Please ensure that you properly document any additions in conformance to Spezi Documentation Guide. You can use this section to describe your solution, but we encourage contributors to document your reasoning and changes using in-line documentation.

:white_check_mark: Testing

Please ensure that the PR meets the testing requirements set by CodeCov and that new functionality is appropriately tested. This section describes important information about the tests and why some elements might not be testable.

:pencil: Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 74.71264% with 44 lines in your changes missing coverage. Please review.

Project coverage is 83.23%. Comparing base (7ffb73d) to head (f082fa8). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...Account/Views/AccountSetup/AccountSetupState.swift 0.00% 35 Missing :warning:
Sources/SpeziAccount/AccountSetup.swift 94.74% 3 Missing :warning:
...Account/ViewModifier/AccountRequiredModifier.swift 81.25% 3 Missing :warning:
Sources/SpeziAccount/Views/AccountSummaryBox.swift 91.67% 3 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73/graphs/tree.svg?width=650&height=150&src=pr&token=AudNwGU7tR&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi)](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ```diff @@ Coverage Diff @@ ## main #73 +/- ## ========================================== - Coverage 83.79% 83.23% -0.55% ========================================== Files 122 121 -1 Lines 5204 5245 +41 ========================================== + Hits 4360 4365 +5 - Misses 844 880 +36 ``` | [Files with missing lines](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | Coverage Δ | | |---|---|---| | [...ces/SpeziAccount/Environment/AccountViewType.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FEnvironment%2FAccountViewType.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvRW52aXJvbm1lbnQvQWNjb3VudFZpZXdUeXBlLnN3aWZ0) | `100.00% <ø> (ø)` | | | [...es/SpeziAccount/Environment/FollowUpBehavior.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FEnvironment%2FFollowUpBehavior.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvRW52aXJvbm1lbnQvRm9sbG93VXBCZWhhdmlvci5zd2lmdA==) | `50.00% <ø> (ø)` | | | [...s/SpeziAccount/Environment/PasswordFieldType.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FEnvironment%2FPasswordFieldType.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvRW52aXJvbm1lbnQvUGFzc3dvcmRGaWVsZFR5cGUuc3dpZnQ=) | `95.00% <ø> (-1.15%)` | :arrow_down: | | [...SpeziAccount/Environment/PreferredSetupStyle.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FEnvironment%2FPreferredSetupStyle.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvRW52aXJvbm1lbnQvUHJlZmVycmVkU2V0dXBTdHlsZS5zd2lmdA==) | `100.00% <ø> (ø)` | | | [...Views/AccountSetup/DefaultAccountSetupHeader.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FViews%2FAccountSetup%2FDefaultAccountSetupHeader.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvVmlld3MvQWNjb3VudFNldHVwL0RlZmF1bHRBY2NvdW50U2V0dXBIZWFkZXIuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...count/Views/AccountSetup/ExistingAccountView.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FViews%2FAccountSetup%2FExistingAccountView.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvVmlld3MvQWNjb3VudFNldHVwL0V4aXN0aW5nQWNjb3VudFZpZXcuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...Account/Views/AccountSetup/FollowUpInfoSheet.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FViews%2FAccountSetup%2FFollowUpInfoSheet.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvVmlld3MvQWNjb3VudFNldHVwL0ZvbGxvd1VwSW5mb1NoZWV0LnN3aWZ0) | `88.97% <100.00%> (+0.16%)` | :arrow_up: | | [Sources/SpeziAccount/Views/SignupFormHeader.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FViews%2FSignupFormHeader.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvVmlld3MvU2lnbnVwRm9ybUhlYWRlci5zd2lmdA==) | `100.00% <100.00%> (ø)` | | | [Sources/SpeziAccount/AccountSetup.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountSetup.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFNldHVwLnN3aWZ0) | `91.42% <94.74%> (-0.66%)` | :arrow_down: | | [...Account/ViewModifier/AccountRequiredModifier.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FViewModifier%2FAccountRequiredModifier.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvVmlld01vZGlmaWVyL0FjY291bnRSZXF1aXJlZE1vZGlmaWVyLnN3aWZ0) | `87.10% <81.25%> (-3.28%)` | :arrow_down: | | ... and [2 more](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Last update [7ffb73d...f082fa8](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/73?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi).
pauljohanneskraft commented 2 months ago

I reverted the changes that are needed in ENGAGE-HF and will open a different PR instead, since this might still be a nice addition, but actually isn't needed urgently anymore.

Feel free to keep this open / ask for adaptions though!

Supereg commented 3 weeks ago

To save you some context switches and time, I went forward and quickly incorporated the changes I had in my comments and rebased onto the latest changes from main. I noticed that in your implementation the loadingExistingAccount was never actually set anymore. I fixed that and merged that state with the isCompletingSetup state you introduced. I used this step to also polish the AccountSetupState implementation a bit and fully exposed it, replacing the previous underscore implementation. Hope that works and feel free to merge the PR if you are happy with the changes. We can release these as 2.1.0 then 👍

PSchmiedmayer commented 3 weeks ago

Amazing; thank you @Supereg!

Feel free to merge the PR if it looks good to you @pauljohanneskraft 🚀