PM-38363: Add a loading ViewState to the PlanScreen#7080
PM-38363: Add a loading ViewState to the PlanScreen#7080david-livefront wants to merge 1 commit into
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR refactors Code Review Details
Note: |
| .onEach { | ||
| // Wait until we are in the Content state so we can update everything appropriately | ||
| mutableStateFlow.first { it.viewState is PlanState.ViewState.Content } | ||
| } |
There was a problem hiding this comment.
❓ QUESTION: This gate suspends the merged collector until the view state reaches Content. In the Error state (e.g. a premium user whose getSubscription() call failed), Content is never reached until the user taps "Try again" and it succeeds, so emissions from specialCircumstanceStateFlow / subscriptionStatusStateFlow are held the entire time the error is on screen.
Details
The updated PlanViewModelTest (around line 170) now seeds subscriptionResult = SUBSCRIPTION_SUCCESS_ACTIVE with the comment "The premium subscription must resolve so the screen reaches a Content state and the special-circumstance flow is processed" — confirming special circumstances are not processed until Content.
Concretely: if a StripePortal / PremiumCheckout special circumstance arrives while the screen is sitting in ViewState.Error, it won't be handled (and its specialCircumstance = null clear won't run) until a retry succeeds. Previously these four flows were collected independently, so they were processed regardless of view state.
Was gating these flows during Error (not just initial Loading) intentional, and is the "blocked until successful retry" behavior acceptable for the special-circumstance path? If so, it may be worth a test covering a special circumstance arriving during Error.
🎟️ Tracking
PM-38363
📔 Objective
This PR refactors the
PlanViewModelandPlanScreento have a top level loading and error state for the initial state.📸 Screenshots