feat: show online and total node count in the title bar (#2209)

This commit is contained in:
James Rich 2025-06-22 02:10:36 +00:00 committed by GitHub
parent 450014a0f6
commit c4c115b901
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View file

@ -29,6 +29,7 @@ import com.geeksville.mesh.database.entity.NodeEntity
import com.geeksville.mesh.model.Node
import com.geeksville.mesh.model.NodeSortOption
import com.geeksville.mesh.util.onlineTimeThreshold
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
@ -133,4 +134,12 @@ class NodeRepository @Inject constructor(
suspend fun insertMetadata(metadata: MetadataEntity) = withContext(dispatchers.io) {
nodeInfoDao.upsert(metadata)
}
val onlineNodeCount: Flow<Int> = nodeInfoDao.nodeDBbyNum().mapLatest { map ->
map.values.count { it.node.lastHeard > onlineTimeThreshold() }
}.flowOn(dispatchers.io).conflate()
val totalNodeCount: Flow<Int> = nodeInfoDao.nodeDBbyNum().mapLatest { map ->
map.values.count()
}.flowOn(dispatchers.io).conflate()
}