From 1458497fc3459cd3658a4729b5eddb549e26173b Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Sun, 26 May 2024 15:42:50 +0800 Subject: [PATCH] Add button to Message page to send a traceroute to a node. As noted in meshtastic/web#179, it would be great to be able to send traceroutes from the web application. This patch adds a button to the messages page that sends a traceroute to the selected node. --- src/pages/Messages.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx index 82325107..2a179208 100644 --- a/src/pages/Messages.tsx +++ b/src/pages/Messages.tsx @@ -7,11 +7,11 @@ import { useDevice } from "@core/stores/deviceStore.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; import { Protobuf, Types } from "@meshtastic/js"; import { getChannelName } from "@pages/Channels.js"; -import { HashIcon } from "lucide-react"; +import { HashIcon, WaypointsIcon } from "lucide-react"; import { useState } from "react"; export const MessagesPage = (): JSX.Element => { - const { channels, nodes, hardware, messages } = useDevice(); + const { channels, nodes, hardware, messages, connection } = useDevice(); const [chatType, setChatType] = useState("broadcast"); const [activeChat, setActiveChat] = useState( @@ -72,6 +72,18 @@ export const MessagesPage = (): JSX.Element => { ? nodes.get(activeChat)?.user?.longName ?? "Unknown" : "Loading..." }`} + actions={[ + { + icon: WaypointsIcon, + async onClick() { + await connection?.traceRoute(nodes.get(activeChat)?.num).then(() => + toast({ + title: `Traceroute sent.`, + }), + ); + }, + }, + ]} > {allChannels.map( (channel) =>