Add formatting logic for multi-hop traceroutes

This commit is contained in:
Tom Fifield
2024-05-27 09:53:20 +08:00
parent be3117651c
commit 056a194ede
2 changed files with 9 additions and 8 deletions
@@ -1,9 +1,5 @@
import type { MessageWithState } from "@app/core/stores/deviceStore.js"; import { useDevice } from "@app/core/stores/deviceStore.js";
import type { Protobuf } from "@meshtastic/js"; import type { Protobuf } from "@meshtastic/js";
import {
WaypointsIcon,
ArrowRightLeft,
} from "lucide-react";
export interface TraceRouteProps { export interface TraceRouteProps {
from?: Protobuf.Mesh.NodeInfo; from?: Protobuf.Mesh.NodeInfo;
@@ -11,11 +7,14 @@ export interface TraceRouteProps {
route?: Protobuf.Mesh.RouteDiscovery; route?: Protobuf.Mesh.RouteDiscovery;
} }
export const TraceRoute = ({ export const TraceRoute = ({
from, from,
to, to,
route, route,
}: TraceRouteProps): JSX.Element => { }: TraceRouteProps): JSX.Element => {
const { nodes } = useDevice();
return route.length == 0 ? ( return route.length == 0 ? (
<div className="ml-5 flex"> <div className="ml-5 flex">
<span className="ml-4 border-l-2 border-l-backgroundPrimary pl-2 text-textPrimary"> <span className="ml-4 border-l-2 border-l-backgroundPrimary pl-2 text-textPrimary">
@@ -25,9 +24,12 @@ export const TraceRoute = ({
) : ( ) : (
<div className="ml-5 flex"> <div className="ml-5 flex">
<span className="ml-4 border-l-2 border-l-backgroundPrimary pl-2 text-textPrimary"> <span className="ml-4 border-l-2 border-l-backgroundPrimary pl-2 text-textPrimary">
{route} {from?.user?.longName}↔
{route.map((hop) => (
nodes.get(hop).user?.longName + "↔"
))}
{to?.user?.longName}
</span> </span>
</div> </div>
); );
}; };
-1
View File
@@ -514,7 +514,6 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
} else { } else {
device.traceroutes.set(traceroute.from, [traceroute]); device.traceroutes.set(traceroute.from, [traceroute]);
} }
console.log(device.traceroutes);
}), }),
); );
}, },