Refactor: Remove "include unmessageable" filter (#1889)

This commit is contained in:
James Rich 2025-05-20 22:08:40 -05:00 committed by GitHub
parent 990cd103d7
commit f6e75e970b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 3 additions and 53 deletions

View file

@ -28,7 +28,6 @@ import com.geeksville.mesh.database.entity.MyNodeEntity
import com.geeksville.mesh.database.entity.NodeEntity
import com.geeksville.mesh.model.Node
import com.geeksville.mesh.model.NodeSortOption
import com.geeksville.mesh.model.isUnmessageableRole
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
@ -97,20 +96,13 @@ class NodeRepository @Inject constructor(
sort: NodeSortOption = NodeSortOption.LAST_HEARD,
filter: String = "",
includeUnknown: Boolean = true,
includeUnmessageable: Boolean = true,
) = nodeInfoDao.getNodes(
sort = sort.sqlValue,
filter = filter,
includeUnknown = includeUnknown,
).mapLatest { list ->
list.map { it.toModel() }.filter { node ->
val isUnmessageable: Boolean = if (node.user.hasIsUnmessagable()) {
node.user.isUnmessagable
} else {
// for older firmwares
node.user.role?.isUnmessageableRole() == true
}
return@filter includeUnmessageable || !isUnmessageable
list.map {
it.toModel()
}
}.flowOn(dispatchers.io).conflate()