fix: show loading overlay immediately for remote config sub-screens#5694
Conversation
When navigating to config/module sub-screens for remote nodes,
Navigation 3's per-entry ViewModelStore creates a new RadioConfigViewModel
with empty state (responseState=Empty). The LaunchedEffect that sets
Loading and fires admin requests only runs after the first composition
frame, resulting in a blank screen flash.
This commit fixes the issue with three targeted changes:
1. Add RadioConfigViewModel.ensureLoadingForRemote() which sets
responseState=Loading when the node is remote and state is still
Empty. This is called synchronously before the content composable
reads the StateFlow.
2. Update configComposable() to call ensureLoadingForRemote() via
remember{} before rendering content, and consolidate the
LaunchedEffect(setResponseStateLoading) into configComposable
instead of duplicating it in each content lambda.
3. Fix LoRaConfigScreen's early return on empty channelList to
render a RadioConfigScreenList with the loading overlay instead
of returning nothing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📄 Docs staleness check — advisoryThis PR modifies user-facing UI source files but does not update any page under
Changed source files: What to check:
New page checklist (if adding a new doc page):
If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the
|
🖼️ Preview staleness check — advisoryThis PR modifies UI composables but does not update any
Changed UI files: What to check:
Adding previews checklist:
If this PR does not require preview updates (e.g., logic-only change, non-visual refactor), add the |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Problem
When navigating to config/module sub-screens (Channels, LoRa, Device config, etc.) for remote nodes, users see a blank screen instead of a loading indicator. This doesn't affect locally-connected Bluetooth nodes.
Root Cause
Navigation 3's
rememberViewModelStoreNavEntryDecoratorcreates a separate ViewModelStore per navigation entry. When navigating fromSettingsRoute.Settings(destNum=X)→ any sub-screen (e.g.,SettingsRoute.ChannelConfig), a brand newRadioConfigViewModelis created with:responseState = Empty(no loading overlay visible)channelList = emptyList()(no content to render)The
LaunchedEffect(Unit)that setsresponseState = Loadingand fires admin requests only runs after the first composition frame — creating a blank screen on that frame.For local nodes, this is imperceptible because the init block subscribes to local database flows that emit data immediately. For remote nodes, data must be fetched over the mesh network, so the blank state persists visibly until the
LaunchedEffectfires.Fix
Three targeted changes:
1.
RadioConfigViewModel.ensureLoadingForRemote()New method that sets
responseState = Loading()when the node is remote and state is stillEmpty. Called synchronously during composition (beforecollectAsStateWithLifecyclereads the StateFlow), so the initial Compose State value already reflectsLoading.2.
configComposable()consolidationUpdated to:
routeInfoparameterensureLoadingForRemote()viaremember{}before content rendersLaunchedEffect(setResponseStateLoading)that was previously duplicated in every content lambda3.
LoRaConfigScreenempty-state handlingPreviously returned early on empty
channelList, rendering nothing (not even a scaffold). Now renders aRadioConfigScreenListwith the loading overlay visible while data loads.Why the Settings menu is unaffected
The parent
SettingsRoute.Settingsentry uses its own entry insettingsGraph(notconfigComposable), soensureLoadingForRemote()is never called for it. The Settings menu continues to start withresponseState = Emptyas before.Testing
ensureLoadingForRemote():spotlessApply,detekt,assembleDebug,test,allTestsall pass