refactor: ensure backward compatibility for PKC encryption

This commit is contained in:
andrekir 2024-09-22 23:01:33 -03:00
parent 6e2848a54a
commit 587c6c91f4
4 changed files with 13 additions and 6 deletions

View file

@ -75,7 +75,6 @@ fun NodeItem(
expanded: Boolean = false,
currentTimeMillis: Long,
) {
val hasPublicKey = !thatNode.user.publicKey.isEmpty
val isUnknownUser = thatNode.user.hwModel == MeshProtos.HardwareModel.UNSET
val unknownShortName = stringResource(id = R.string.unknown_node_short_name)
val longName = thatNode.user.longName.ifEmpty { stringResource(id = R.string.unknown_username) }
@ -163,7 +162,7 @@ fun NodeItem(
)
Text(
modifier = Modifier.weight(1f),
text = if (hasPublicKey) "🔒 $longName" else longName,
text = if (thatNode.hasPKC) "🔒 $longName" else longName,
style = style,
textDecoration = TextDecoration.LineThrough.takeIf { isIgnored },
softWrap = true,

View file

@ -90,7 +90,8 @@ class UsersFragment : ScreenFragment("Users"), Logging {
}
private fun navigateToMessages(node: NodeEntity) = node.user.let { user ->
val channel = if (user.publicKey.isEmpty) node.channel else DataPacket.PKC_CHANNEL_INDEX
val hasPKC = model.ourNodeInfo.value?.hasPKC == true && node.hasPKC // TODO use meta.hasPKC
val channel = if (hasPKC) DataPacket.PKC_CHANNEL_INDEX else node.channel
val contactKey = "$channel${user.id}"
info("calling MessagesFragment filter: $contactKey")
parentFragmentManager.navigateToMessages(contactKey, user.longName)