feat: create NodeEntity.isUnknownUser property

This commit is contained in:
andrekir
2024-10-14 17:16:45 -03:00
parent 2050cd0b4b
commit eacf3a87a0
3 changed files with 3 additions and 4 deletions

View File

@@ -161,9 +161,7 @@ class NodeInfoDaoTest {
@Test
fun testIncludeUnknownIsFalse() = runBlocking {
val nodes = getNodes(includeUnknown = false)
val containsUnsetNode = nodes.any { node ->
node.user.hwModel == MeshProtos.HardwareModel.UNSET
}
val containsUnsetNode = nodes.any { it.isUnknownUser }
assertFalse(containsUnsetNode)
}

View File

@@ -84,6 +84,7 @@ data class NodeEntity(
return (if (brightness > 0.5) Color.BLACK else Color.WHITE) to Color.rgb(r, g, b)
}
val isUnknownUser get() = user.hwModel == MeshProtos.HardwareModel.UNSET
val hasPKC get() = !user.publicKey.isEmpty
val errorByteString: ByteString get() = ByteString.copyFrom(ByteArray(32) { 0 })
val mismatchKey get() = user.publicKey == errorByteString

View File

@@ -79,7 +79,7 @@ fun NodeItem(
expanded: Boolean = false,
currentTimeMillis: Long,
) {
val isUnknownUser = thatNode.user.hwModel == MeshProtos.HardwareModel.UNSET
val isUnknownUser = thatNode.isUnknownUser
val unknownShortName = stringResource(id = R.string.unknown_node_short_name)
val longName = thatNode.user.longName.ifEmpty { stringResource(id = R.string.unknown_username) }