mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Move ignoredNodeCount to UI state
This commit is contained in:
parent
6fda0da91a
commit
a029cff1ae
2 changed files with 6 additions and 10 deletions
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue