Skip to content

Commit

Permalink
Merge pull request #306 from KomelT/feature/better-unknown
Browse files Browse the repository at this point in the history
Unknown nodes
  • Loading branch information
Hunter275 authored Sep 17, 2024
2 parents 57d0d27 + c0cb059 commit 8cfcd7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/PageComponents/Messages/TraceRoute.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,7 +25,10 @@ export const TraceRoute = ({
<div className="ml-5 flex">
<span className="ml-4 border-l-2 border-l-backgroundPrimary pl-2 text-textPrimary">
{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}
</span>
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 (
<>
Expand Down Expand Up @@ -56,7 +59,7 @@ export const MessagesPage = (): JSX.Element => {
{filteredNodes.map((node) => (
<SidebarButton
key={node.num}
label={node.user?.longName ?? "Unknown"}
label={node.user?.longName ?? `!${numberToHexUnpadded(node.num)}`}
active={activeChat === node.num}
onClick={() => {
setChatType("direct");
Expand All @@ -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={
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)}`)}
</h1>,

<Mono key="model">
Expand Down

0 comments on commit 8cfcd7b

Please sign in to comment.