* chore(deps): bump @noble/curves from 1.9.7 to 2.2.0 Bumps [@noble/curves](https://github.com/paulmillr/noble-curves) from 1.9.7 to 2.2.0. - [Release notes](https://github.com/paulmillr/noble-curves/releases) - [Commits](https://github.com/paulmillr/noble-curves/compare/1.9.7...2.2.0) --- updated-dependencies: - dependency-name: "@noble/curves" dependency-version: 2.2.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * refactor(web): migrate @noble/curves imports to v2 paths - Move numberToHexUnpadded import from @noble/curves/abstract/utils to @noble/curves/utils.js (abstract/utils subpath removed in v2). - Update @noble/curves/ed25519 to @noble/curves/ed25519.js to match required sub-import file extensions. - Rename x25519.utils.randomPrivateKey() to randomSecretKey() (v2 API). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dan Ditomaso <dan.ditomaso@gmail.com>
94 lines
2.9 KiB
TypeScript
94 lines
2.9 KiB
TypeScript
import { useNodeAsProto } from "@core/hooks/useNodesAsProto.ts";
|
|
import type { Protobuf, Types } from "@meshtastic/sdk";
|
|
import { numberToHexUnpadded } from "@noble/curves/utils.js";
|
|
import { useTranslation } from "react-i18next";
|
|
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "../UI/Dialog.tsx";
|
|
|
|
export interface LocationResponseDialogProps {
|
|
location: Types.PacketMetadata<Protobuf.Mesh.Position> | undefined;
|
|
open: boolean;
|
|
onOpenChange: () => void;
|
|
}
|
|
|
|
export const LocationResponseDialog = ({
|
|
location,
|
|
open,
|
|
onOpenChange,
|
|
}: LocationResponseDialogProps) => {
|
|
const { t } = useTranslation("dialog");
|
|
const from = useNodeAsProto(location?.from ?? 0);
|
|
const longName =
|
|
from?.user?.longName ??
|
|
(from ? `!${numberToHexUnpadded(from?.num)}` : t("unknown.shortName"));
|
|
const shortName =
|
|
from?.user?.shortName ??
|
|
(from
|
|
? `${numberToHexUnpadded(from?.num).substring(0, 4)}`
|
|
: t("unknown.shortName"));
|
|
|
|
const position = location?.data;
|
|
|
|
const hasCoordinates =
|
|
position &&
|
|
typeof position.latitudeI === "number" &&
|
|
typeof position.longitudeI === "number" &&
|
|
typeof position.altitude === "number";
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent>
|
|
<DialogClose />
|
|
<DialogHeader>
|
|
<DialogTitle>
|
|
{t("locationResponse.title", {
|
|
interpolation: { escapeValue: false },
|
|
identifier: `${longName} (${shortName})`,
|
|
})}
|
|
</DialogTitle>
|
|
</DialogHeader>
|
|
<DialogDescription>
|
|
{hasCoordinates ? (
|
|
<div className="ml-5 flex">
|
|
<span className="ml-4 border-l-2 border-l-backgroundPrimary pl-2 text-textPrimary">
|
|
<p>
|
|
{t("locationResponse.coordinates")}
|
|
<a
|
|
className="text-blue-500 dark:text-blue-400"
|
|
href={`https://www.openstreetmap.org/?mlat=${
|
|
position.latitudeI ?? 0 / 1e7
|
|
}&mlon=${position.longitudeI ?? 0 / 1e7}&layers=N`}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
>
|
|
{" "}
|
|
{position.latitudeI ?? 0 / 1e7},{" "}
|
|
{position.longitudeI ?? 0 / 1e7}
|
|
</a>
|
|
</p>
|
|
<p>
|
|
{t("locationResponse.altitude")} {position.altitude}
|
|
{(position.altitude ?? 0) < 1
|
|
? t("unit.meter.one")
|
|
: t("unit.meter.plural")}
|
|
</p>
|
|
</span>
|
|
</div>
|
|
) : (
|
|
// Optional: Show a message if coordinates are not available
|
|
<p className="text-textPrimary">
|
|
{t("locationResponse.noCoordinates")}
|
|
</p>
|
|
)}
|
|
</DialogDescription>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|