Skip to content

Commit

Permalink
feat: create NodeEntity.isUnknownUser property
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Oct 14, 2024
1 parent 2050cd0 commit eacf3a8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/geeksville/mesh/ui/NodeItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down

0 comments on commit eacf3a8

Please sign in to comment.