[Dynamic dashboard] Improve "has orders" logic#11469
Conversation
| coroutineScope { | ||
| launch { fetchPlugins(site) } |
There was a problem hiding this comment.
The change to use coroutineScope with launch builders is to allow parallel requests.
| // Fetch a fresh list of order status options | ||
| dispatcher.dispatch( | ||
| WCOrderActionBuilder | ||
| .newFetchOrderStatusOptionsAction(FetchOrderStatusOptionsPayload(site)) | ||
| ) |
There was a problem hiding this comment.
This was moved to the SiteObserver class to ensure it's called both when the app is launched, and when the selected site is changed.
| // Update onboarding completed status based on the tasks completion status | ||
| if (mobileSupportedTasks.all { it.isComplete }) { | ||
| appPrefs.updateOnboardingCompletedStatus(selectedSite.getSelectedSiteId(), true) | ||
| } else if (appPrefs.isOnboardingCompleted(selectedSite.getSelectedSiteId())) { | ||
| appPrefs.updateOnboardingCompletedStatus(selectedSite.getSelectedSiteId(), false) | ||
| } |
There was a problem hiding this comment.
Moving this logic here instead of ShouldShowOnboarding was to make sure we don't miss updating the status when the onboarding tasks list is empty, this happened to me on one of my sites, and the onboarding card kept being shown then dismissed on each launch.
There was a problem hiding this comment.
Nice! I saw this as well on my site and planned to look into it.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #11469 +/- ##
========================================
Coverage ? 40.82%
Complexity ? 5219
========================================
Files ? 1072
Lines ? 62936
Branches ? 8615
========================================
Hits ? 25692
Misses ? 34927
Partials ? 2317 ☔ View full report in Codecov by Sentry. |
This is an improvement when the app doesn't any cached orders to tell if the store has orders or not, and would avoid flickering on the main screen during initial load.
This fixes issues where we miss updating the status when we don't have any tasks.
The new logic means we'll fetch on each app launch in addition to site switching.
8e5b448 to
b4acb19
Compare
| // Update onboarding completed status based on the tasks completion status | ||
| if (mobileSupportedTasks.all { it.isComplete }) { | ||
| appPrefs.updateOnboardingCompletedStatus(selectedSite.getSelectedSiteId(), true) | ||
| } else if (appPrefs.isOnboardingCompleted(selectedSite.getSelectedSiteId())) { | ||
| appPrefs.updateOnboardingCompletedStatus(selectedSite.getSelectedSiteId(), false) | ||
| } |
There was a problem hiding this comment.
Nice! I saw this as well on my site and planned to look into it.
Description
This PR updates the logic of deciding on the availability of the stats cards, for more information check p1715164179010139-slack-C03L1NF1EA3
Testing instructions
OrderEntityandWCOrderStatusOptionif you want to do it manually)Images/gif
Screen_recording_20240508_104705.webm
Screen_recording_20240508_112721.webm
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.