Skip to content

refactor(settings): improve destination node handling in RadioConfigViewModel#4790

Merged
jamesarich merged 1 commit intomainfrom
fix/remote-admin
Mar 14, 2026
Merged

refactor(settings): improve destination node handling in RadioConfigViewModel#4790
jamesarich merged 1 commit intomainfrom
fix/remote-admin

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

@jamesarich jamesarich commented Mar 14, 2026

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.

…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]>
@github-actions github-actions bot added the bugfix PR tag label Mar 14, 2026
@jamesarich jamesarich enabled auto-merge March 14, 2026 02:23
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 12.23%. Comparing base (427c0f3) to head (b955939).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tic/feature/settings/radio/RadioConfigViewModel.kt 0.00% 6 Missing ⚠️
...rg/meshtastic/app/navigation/SettingsNavigation.kt 0.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@jamesarich jamesarich added this pull request to the merge queue Mar 14, 2026
Merged via the queue into main with commit 06f002a Mar 14, 2026
10 of 12 checks passed
@jamesarich jamesarich deleted the fix/remote-admin branch March 14, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant