refactor(settings): improve destination node handling in RadioConfigViewModel#4790
Merged
jamesarich merged 1 commit intomainfrom Mar 14, 2026
Merged
refactor(settings): improve destination node handling in RadioConfigViewModel#4790jamesarich merged 1 commit intomainfrom
jamesarich merged 1 commit intomainfrom
Conversation
…iewModel
This commit refactors how the destination node identifier (`destNum`) is handled in `RadioConfigViewModel` to better support navigation-driven updates across Android and Desktop platforms. By moving from a static `SavedStateHandle` retrieval to a reactive `MutableStateFlow`, the ViewModel can now dynamically update its state when navigation routes change.
Specific changes include:
- **RadioConfigViewModel**:
- Replaced direct `SavedStateHandle` access for `destNum` with `_destNumFlow`.
- Added `initDestNum(id: Int?)` to allow manual initialization/updates of the destination node ID.
- Updated internal flows to use `combine` with `_destNumFlow` for tracking the current `destNode` and determining `isLocal` status.
- **Navigation (Android & Desktop)**:
- Introduced `getRadioConfigViewModel(backStack)` helper functions in `SettingsNavigation.kt` (Android) and `DesktopSettingsNavigation.kt` (Desktop).
- Implemented a `LaunchedEffect` in the helper to extract `destNum` from the latest `Settings` or `SettingsGraph` route in the backstack and initialize the ViewModel.
- Updated all settings-related navigation entries to use this new helper, ensuring consistent ViewModel state across the settings sub-graph.
- Updated `configComposable` and `desktopConfigComposable` signatures to accept the `backStack` parameter.
Signed-off-by: James Rich <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4790 +/- ##
=======================================
Coverage 12.23% 12.23%
=======================================
Files 530 530
Lines 17753 17753
Branches 2651 2652 +1
=======================================
Hits 2172 2172
Misses 15267 15267
Partials 314 314 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit refactors how the destination node identifier (
destNum) is handled inRadioConfigViewModelto better support navigation-driven updates across Android and Desktop platforms. By moving from a staticSavedStateHandleretrieval to a reactiveMutableStateFlow, the ViewModel can now dynamically update its state when navigation routes change.Specific changes include:
SavedStateHandleaccess fordestNumwithdestNumFlow.initDestNum(id: Int?)to allow manual initialization/updates of the destination node ID.combinewithdestNumFlowfor tracking the currentdestNodeand determiningisLocalstatus.getRadioConfigViewModel(backStack)helper functions inSettingsNavigation.kt(Android) andDesktopSettingsNavigation.kt(Desktop).LaunchedEffectin the helper to extractdestNumfrom the latestSettingsorSettingsGraphroute in the backstack and initialize the ViewModel.configComposableanddesktopConfigComposablesignatures to accept thebackStackparameter.