From 4ad80b019c1e9ed1de5b6c201c5a99302820bbc8 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Tue, 26 Aug 2025 08:28:38 -0500 Subject: [PATCH] refactor(connections): use collectAsStateWithLifecycle for UI state (#2850) Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> --- .../java/com/geeksville/mesh/ui/connections/Connections.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/connections/Connections.kt b/app/src/main/java/com/geeksville/mesh/ui/connections/Connections.kt index aa69cfbd2..8827002bd 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/connections/Connections.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/connections/Connections.kt @@ -134,16 +134,15 @@ fun ConnectionsScreen( onConfigNavigate: (Route) -> Unit, ) { val radioConfigState by radioConfigViewModel.radioConfigState.collectAsStateWithLifecycle() - val config by uiViewModel.localConfig.collectAsState() + val config by uiViewModel.localConfig.collectAsStateWithLifecycle() val currentRegion = config.lora.region val scrollState = rememberScrollState() val scanStatusText by scanModel.errorText.observeAsState("") - val connectionState by uiViewModel.connectionState.collectAsState(ConnectionState.DISCONNECTED) + val connectionState by uiViewModel.connectionState.collectAsStateWithLifecycle(ConnectionState.DISCONNECTED) val scanning by scanModel.spinner.collectAsStateWithLifecycle(false) - val receivingLocationUpdates by uiViewModel.receivingLocationUpdates.collectAsState(false) val context = LocalContext.current val app = (context.applicationContext as GeeksvilleApplication) - val info by uiViewModel.myNodeInfo.collectAsState() + val info by uiViewModel.myNodeInfo.collectAsStateWithLifecycle() val selectedDevice by scanModel.selectedNotNullFlow.collectAsStateWithLifecycle() val bluetoothEnabled by bluetoothViewModel.enabled.collectAsStateWithLifecycle(false) val regionUnset =