From b3542c76aaf8441e0de1e77e91bdd59fe2c8178d Mon Sep 17 00:00:00 2001 From: James Rich Date: Wed, 6 May 2026 12:46:42 -0500 Subject: [PATCH] fix: remove circular StateFlow observation in RadioConfigViewModel The combine(serviceRepository.connectionState, radioConfigState) pattern subscribed to the ViewModel's own output StateFlow, causing redundant re-evaluations on every state change. Replace with direct observation of the source connectionState flow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../feature/settings/radio/RadioConfigViewModel.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt index 69c9d74c2..20089e9bd 100644 --- a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt +++ b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt @@ -235,9 +235,10 @@ open class RadioConfigViewModel( .onEach { manifest -> _radioConfigState.update { it.copy(fileManifest = manifest) } } .launchIn(viewModelScope) - combine(serviceRepository.connectionState, radioConfigState) { connState, _ -> - _radioConfigState.update { it.copy(connected = connState == ConnectionState.Connected) } - } + serviceRepository.connectionState + .onEach { connState -> + _radioConfigState.update { it.copy(connected = connState == ConnectionState.Connected) } + } .launchIn(viewModelScope) combine(nodeRepository.myNodeInfo, destNumFlow) { ni, id ->