Move ignoredNodeCount to UI state

This commit is contained in:
Phil Oliver 2025-11-18 02:11:25 -05:00
parent 6fda0da91a
commit a029cff1ae
2 changed files with 6 additions and 10 deletions

View file

@ -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,
)
}

View file

@ -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<List<Node>> =
nodeRepository.getNodes().stateInWhileSubscribed(initialValue = emptyList())
fun setFilterText(filterText: String) {
savedStateHandle[KEY_FILTER_TEXT] = value
}
@ -173,6 +171,7 @@ data class NodesUiState(
val nodes: List<Node> = emptyList(),
val distanceUnits: Int = 0,
val tempInFahrenheit: Boolean = false,
val ignoredNodeCount: Int = 0,
)
data class NodeFilterState(