From 3a11ca9a1cd2b38d2e354d1c8817058bbac4f1f1 Mon Sep 17 00:00:00 2001 From: andrekir Date: Sun, 18 Aug 2024 09:34:47 -0300 Subject: [PATCH] refactor: add `shortName` to traceroute response closes #1164 --- .../com/geeksville/mesh/service/MeshService.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index e81148d01..361622979 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -442,8 +442,12 @@ class MeshService : Service(), Logging { } } - private fun getLongName(num: Int) = - nodeDBbyNodeNum[num]?.user?.longName ?: getString(R.string.unknown_username) + private fun getUserName(num: Int): String { + val user = nodeDBbyNodeNum[num]?.user + val longName = user?.longName ?: getString(R.string.unknown_username) + val shortName = user?.shortName ?: DataPacket.nodeNumToDefaultId(num) + return "$longName ($shortName)" + } private val numNodes get() = nodeDBbyNodeNum.size @@ -733,9 +737,9 @@ class MeshService : Service(), Logging { if (data.wantResponse) return // ignore data from traceroute requests val parsed = MeshProtos.RouteDiscovery.parseFrom(data.payload) radioConfigRepository.setTracerouteResponse(buildString { - append("${getLongName(packet.to)} --> ") - parsed.routeList.forEach { num -> append("${getLongName(num)} --> ") } - append(getLongName(packet.from)) + append("${getUserName(packet.to)} --> ") + parsed.routeList.forEach { num -> append("${getUserName(num)} --> ") } + append(getUserName(packet.from)) }) }