From a2a9b372382e68aa499a5e8f23ee7e28ccf34389 Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Tue, 17 Sep 2024 21:08:35 +0200 Subject: [PATCH] Unknown to node hex on other missing places --- src/components/PageComponents/Messages/TraceRoute.tsx | 6 +++++- src/pages/Messages.tsx | 7 +++++-- src/pages/Nodes.tsx | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/PageComponents/Messages/TraceRoute.tsx b/src/components/PageComponents/Messages/TraceRoute.tsx index 15d3bdea..e2adf30e 100644 --- a/src/components/PageComponents/Messages/TraceRoute.tsx +++ b/src/components/PageComponents/Messages/TraceRoute.tsx @@ -1,5 +1,6 @@ import { useDevice } from "@app/core/stores/deviceStore.js"; import type { Protobuf } from "@meshtastic/js"; +import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; export interface TraceRouteProps { from?: Protobuf.Mesh.NodeInfo; @@ -24,7 +25,10 @@ export const TraceRoute = ({
{to?.user?.longName}↔ - {route.map((hop) => `${nodes.get(hop)?.user?.longName ?? "Unknown"}↔`)} + {route.map((hop) => { + const node = nodes.get(hop); + return `${node?.user?.longName ?? (node?.num ? numberToHexUnpadded(node.num) : "Unknown")}↔`; + })} {from?.user?.longName}
diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx index c308743d..4e7fbae9 100644 --- a/src/pages/Messages.tsx +++ b/src/pages/Messages.tsx @@ -7,6 +7,7 @@ import { useToast } from "@core/hooks/useToast.js"; import { useDevice } from "@core/stores/deviceStore.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; import { Protobuf, Types } from "@meshtastic/js"; +import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { getChannelName } from "@pages/Channels.js"; import { HashIcon, LockIcon, LockOpenIcon, WaypointsIcon } from "lucide-react"; import { useState } from "react"; @@ -28,6 +29,8 @@ export const MessagesPage = (): JSX.Element => { ); const currentChannel = channels.get(activeChat); const { toast } = useToast(); + const node = nodes.get(activeChat); + const nodeHex = node?.num ? numberToHexUnpadded(node.num) : "Unknown"; return ( <> @@ -56,7 +59,7 @@ export const MessagesPage = (): JSX.Element => { {filteredNodes.map((node) => ( { setChatType("direct"); @@ -73,7 +76,7 @@ export const MessagesPage = (): JSX.Element => { chatType === "broadcast" && currentChannel ? getChannelName(currentChannel) : chatType === "direct" && nodes.get(activeChat) - ? nodes.get(activeChat)?.user?.longName ?? "Unknown" + ? nodes.get(activeChat)?.user?.longName ?? nodeHex : "Loading..." }`} actions={ diff --git a/src/pages/Nodes.tsx b/src/pages/Nodes.tsx index 10c51f19..038d81a8 100644 --- a/src/pages/Nodes.tsx +++ b/src/pages/Nodes.tsx @@ -8,6 +8,7 @@ import { TimeAgo } from "@components/generic/Table/tmp/TimeAgo.js"; import { useDevice } from "@core/stores/deviceStore.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; import { Protobuf } from "@meshtastic/js"; +import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { LockIcon, LockOpenIcon, TrashIcon } from "lucide-react"; import { Fragment } from "react"; import { base16 } from "rfc4648"; @@ -50,7 +51,7 @@ export const NodesPage = (): JSX.Element => { ? `Meshtastic ${base16 .stringify(node.user?.macaddr.subarray(4, 6) ?? []) .toLowerCase()}` - : `UNK: ${node.num}`)} + : `!${numberToHexUnpadded(node.num)}`)} ,