From a029cff1ae5f0fc5ba1665b707616e65d46b9db7 Mon Sep 17 00:00:00 2001 From: Phil Oliver <3497406+poliver@users.noreply.github.com> Date: Tue, 18 Nov 2025 02:11:25 -0500 Subject: [PATCH] Move ignoredNodeCount to UI state --- .../meshtastic/feature/node/list/NodeListScreen.kt | 5 +---- .../meshtastic/feature/node/list/NodeListViewModel.kt | 11 +++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListScreen.kt b/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListScreen.kt index 42dc686df..b8c188e9b 100644 --- a/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListScreen.kt +++ b/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListScreen.kt @@ -96,9 +96,6 @@ fun NodeListScreen( ) { val state by viewModel.uiState.collectAsStateWithLifecycle() - val unfilteredNodes by viewModel.unfilteredNodeList.collectAsStateWithLifecycle() - val ignoredNodeCount = unfilteredNodes.count { it.isIgnored } - val listState = rememberLazyListState() val coroutineScope = rememberCoroutineScope() @@ -172,7 +169,7 @@ fun NodeListScreen( onToggleOnlyDirect = { viewModel.nodeFilterPreferences.toggleOnlyDirect() }, showIgnored = state.filter.showIgnored, onToggleShowIgnored = { viewModel.nodeFilterPreferences.toggleShowIgnored() }, - ignoredNodeCount = ignoredNodeCount, + ignoredNodeCount = state.ignoredNodeCount, ) } diff --git a/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListViewModel.kt b/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListViewModel.kt index 6e29fcbea..645fca925 100644 --- a/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListViewModel.kt +++ b/feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListViewModel.kt @@ -40,7 +40,6 @@ import org.meshtastic.core.database.model.NodeSortOption import org.meshtastic.core.datastore.UiPreferencesDataSource import org.meshtastic.core.service.ConnectionState import org.meshtastic.core.service.ServiceRepository -import org.meshtastic.core.ui.viewmodel.stateInWhileSubscribed import org.meshtastic.feature.node.model.isEffectivelyUnmessageable import org.meshtastic.proto.AdminProtos import org.meshtastic.proto.ConfigProtos @@ -78,6 +77,7 @@ constructor( val onlyOnline by nodeFilterPreferences.onlyOnline.collectAsState() val onlyDirect by nodeFilterPreferences.onlyDirect.collectAsState() val showIgnored by nodeFilterPreferences.showIgnored.collectAsState() + val unfilteredNodes by nodeRepository.getNodes().collectAsState(emptyList()) val filter = NodeFilterState( @@ -93,7 +93,7 @@ constructor( .collectAsState(NodeSortOption.VIA_FAVORITE) val profile by radioConfigRepository.deviceProfileFlow.collectAsState(deviceProfile {}) - val nodeList by + val filteredNodes by nodeRepository .getNodes( sort = sort, @@ -130,16 +130,14 @@ constructor( connectionState = connectionState, sort = sort, filter = filter, - nodes = nodeList, + nodes = filteredNodes, distanceUnits = profile.config.display.units.number, tempInFahrenheit = profile.moduleConfig.telemetry.environmentDisplayFahrenheit, + ignoredNodeCount = unfilteredNodes.count { it.isIgnored }, ) } } - val unfilteredNodeList: StateFlow> = - nodeRepository.getNodes().stateInWhileSubscribed(initialValue = emptyList()) - fun setFilterText(filterText: String) { savedStateHandle[KEY_FILTER_TEXT] = value } @@ -173,6 +171,7 @@ data class NodesUiState( val nodes: List = emptyList(), val distanceUnits: Int = 0, val tempInFahrenheit: Boolean = false, + val ignoredNodeCount: Int = 0, ) data class NodeFilterState(