Fix dashboard loading message state reset - #23254
Conversation
|
Thanks for picking this up 🙏 I don’t think this change can fix #20411 — clearValue() isn’t on the path where the bug happens. The issue repros on a fresh login, which goes through buildDashboardOrSiteItems() → buildCards(site) (MySiteViewModel.kt:323). clearValue() only runs in the else branch at line 327 (dashboard not shown) and in onSitePicked(). The flash actually comes from buildCards(): personalizeCardViewModelSlice.buildCard() posts immediately while cardViewModelSlice.buildCard(site) waits on the network. Since mergeUiModels() adds the no-cards message inside personalizeCard?.let { ... }, we briefly render it with no cards yet — the state in the issue’s screenshot. Also worth noting the existing test uses order-agnostic verify(), so it passes either way and doesn’t confirm the new ordering. If you want to keep going, the fix belongs in mergeUiModels() — gate the no-cards message on the cards having finished loading rather than on the personalize card being present. Watch out that CardViewModelSlice.clearValue() posts a non-null empty CardsState.Success, so a null check alone won’t do it. Happy to review a follow-up. Leaving this open for now. |
Description
Fixes #20411
Fixes an issue where the dashboard could incorrectly show the "No cards" message while clearing dashboard card states.
The
PersonalizeCardViewModelSlicestate is used to determine whether the dashboard should be displayed. Previously, the personalize card value was cleared after other card states, which could leave the dashboard in an incorrect intermediate state.This change moves
personalizeCardViewModelSlice.clearValue()to the beginning ofclearValue()so all dependent card states are reset in the correct order.Testing instructions
Test case title: Verify dashboard loading state reset
Test case title: Unit test verification
./gradlew :WordPress:testWordPressDebugUnitTest --tests "*DashboardCardsViewModelSliceTest"