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

[Wear App] Remove NavController injection from all Wear ViewModels #12639

Merged
merged 14 commits into from
Sep 26, 2024

Conversation

ThomazFB
Copy link
Contributor

@ThomazFB ThomazFB commented Sep 18, 2024

Summary

Removes from the Wear app architectural design the practice of injecting the NavController into every VIewModel with a navigation action. This is not recommended due to the fact that the UI grants a NavController, and when the screen is destroyed, the NavController reference will also be lost.

This PR fixes it by keeping all NavControllers inside the Composables. The result is a simpler way to create the Wear ViewModels, without the need of using assisted injections.

How to Test

Make sure all screens with navigations (Login and Order List) are still working, even during configuration changes

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@dangermattic
Copy link
Collaborator

dangermattic commented Sep 18, 2024

1 Warning
⚠️ This PR is assigned to the milestone 20.6. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 18, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit5a2eaa8
Direct Downloadwoocommerce-prototype-build-pr12639-5a2eaa8.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 18, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit5a2eaa8
Direct Downloadwoocommerce-wear-prototype-build-pr12639-5a2eaa8.apk

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 40.58%. Comparing base (413617c) to head (5a2eaa8).
Report is 15 commits behind head on trunk.

Files with missing lines Patch % Lines
...java/com/woocommerce/android/wear/ui/Navigation.kt 0.00% 2 Missing ⚠️
...woocommerce/android/wear/ui/login/FetchSiteData.kt 0.00% 1 Missing ⚠️
...android/wear/ui/orders/list/OrdersListViewModel.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #12639   +/-   ##
=========================================
  Coverage     40.58%   40.58%           
  Complexity     5699     5699           
=========================================
  Files          1232     1232           
  Lines         69413    69397   -16     
  Branches       9617     9617           
=========================================
- Hits          28170    28164    -6     
+ Misses        38651    38642    -9     
+ Partials       2592     2591    -1     
Flag Coverage Δ
40.58% <66.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from issue/update-wear-with-play-store-review-changes to trunk September 19, 2024 23:38
@ThomazFB ThomazFB added this to the 20.6 milestone Sep 25, 2024
@ThomazFB ThomazFB added type: enhancement A request for an enhancement. feature: android wear labels Sep 25, 2024
@ThomazFB ThomazFB marked this pull request as ready for review September 25, 2024 23:33
@ThomazFB ThomazFB changed the title Issue/remove wear view models nav controllers [Wear App] Remove NavController injection from all Wear ViewModels Sep 25, 2024
@ThomazFB ThomazFB merged commit 4b51731 into trunk Sep 26, 2024
15 checks passed
@ThomazFB ThomazFB deleted the issue/remove-wear-view-models-nav-controllers branch September 26, 2024 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: android wear type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants