format the node id

This commit is contained in:
ajvpot
2025-08-01 07:53:15 +02:00
parent 63188c3b2c
commit 527cc526b5
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
import React from 'react';
import moment from "moment";
import { formatPublicKey } from '../lib/meshcore';
type NodePosition = {
node_id: string;
@@ -144,7 +145,7 @@ export function ClusterMarker({ children }: ClusterMarkerProps) {
export function PopupContent({ node }: PopupContentProps) {
return (
<div>
<div><b>ID:</b> {node.node_id}</div>
<div><b>ID:</b> {node.type === "meshcore" ? formatPublicKey(node.node_id) : node.node_id}</div>
<div><b>Full Name:</b> {node.name ?? "-"}</div>
<div><b>Short Name:</b> {node.short_name ?? "-"}</div>
<div><b>Type:</b> {node.type ?? "-"}</div>
+6
View File
@@ -191,4 +191,10 @@ export async function decryptMeshcoreGroupMessage({
});
}
return null;
}
export function formatPublicKey(pubKey: string): string {
// Take the first 8 characters, add ellipsis, and then the last 8 characters
const formattedKey = `<${pubKey.slice(0, 8)}...${pubKey.slice(-8)}>`;
return formattedKey;
}