From 163642fbf9695cb8a1a1b25a0459c74e3c7b25c8 Mon Sep 17 00:00:00 2001 From: philon- Date: Wed, 17 Sep 2025 23:15:38 +0200 Subject: [PATCH] Review fixes Co-Authored-By: Dan Ditomaso --- .../web/public/i18n/locales/en/common.json | 3 +- .../PageComponents/Map/Layers/NodesLayer.tsx | 4 +- .../PageComponents/Map/Layers/SNRLayer.tsx | 42 +-- .../Map/Layers/WaypointLayer.tsx | 4 +- .../Map/Popups/WaypointDetail.tsx | 258 ++++++++++-------- 5 files changed, 169 insertions(+), 142 deletions(-) diff --git a/packages/web/public/i18n/locales/en/common.json b/packages/web/public/i18n/locales/en/common.json index 9c1c0f71..6c25fc9f 100644 --- a/packages/web/public/i18n/locales/en/common.json +++ b/packages/web/public/i18n/locales/en/common.json @@ -66,7 +66,8 @@ "year": { "one": "Year", "plural": "Years" }, "snr": "SNR", "volt": { "one": "Volt", "plural": "Volts", "suffix": "V" }, - "record": { "one": "Records", "plural": "Records" } + "record": { "one": "Records", "plural": "Records" }, + "degree": { "one": "Degree", "plural": "Degrees", "suffix": "°" } }, "security": { "0bit": "Empty", diff --git a/packages/web/src/components/PageComponents/Map/Layers/NodesLayer.tsx b/packages/web/src/components/PageComponents/Map/Layers/NodesLayer.tsx index 1a14f4ad..d4f22bc5 100644 --- a/packages/web/src/components/PageComponents/Map/Layers/NodesLayer.tsx +++ b/packages/web/src/components/PageComponents/Map/Layers/NodesLayer.tsx @@ -83,7 +83,7 @@ export const NodesLayer = ({ : undefined; // Always render all node markers in the cluster - nodes.forEach((node, i) => { + for (const [i, node] of nodes.entries()) { const isHead = i === 0; rendered.push( @@ -109,7 +109,7 @@ export const NodesLayer = ({ }} />, ); - }); + } if (nodes.length > 1) { rendered.push( diff --git a/packages/web/src/components/PageComponents/Map/Layers/SNRLayer.tsx b/packages/web/src/components/PageComponents/Map/Layers/SNRLayer.tsx index a4a83461..febb3a3c 100644 --- a/packages/web/src/components/PageComponents/Map/Layers/SNRLayer.tsx +++ b/packages/web/src/components/PageComponents/Map/Layers/SNRLayer.tsx @@ -165,6 +165,21 @@ function makeFeature( }; } +function pushIfFeature( + a: number, + b: number, + aPos: LngLat, + bPos: LngLat, + snr: number, + curved: boolean, + features: Feature[], +) { + const feat = makeFeature(a, b, aPos, bPos, snr, curved); + if (feat) { + features.push(feat); + } +} + function generateNeighborLines( neighborInfos: NeighborInfos[], ): FeatureCollection { @@ -215,26 +230,15 @@ function generateNeighborLines( if (pair.ab && pair.ba) { // both directions → two arcs - const feat1 = makeFeature(pair.a, pair.b, aPos, bPos, pair.ab, true); - const feat2 = makeFeature(pair.b, pair.a, bPos, aPos, pair.ba, true); - - if (feat1) { - features.push(feat1); - } - if (feat2) { - features.push(feat2); - } - } else if (pair.ab) { - // only a->b, straight - const feat = makeFeature(pair.a, pair.b, aPos, bPos, pair.ab, false); - if (feat) { - features.push(feat); + pushIfFeature(pair.a, pair.b, aPos, bPos, pair.ab, true, features); + pushIfFeature(pair.b, pair.a, bPos, aPos, pair.ba, true, features); + } else { + // only one direction → straight + if (pair.ab) { + pushIfFeature(pair.a, pair.b, aPos, bPos, pair.ab, false, features); } - } else if (pair.ba) { - // only b->a, straight - const feat = makeFeature(pair.b, pair.a, bPos, aPos, pair.ba, false); - if (feat) { - features.push(feat); + if (pair.ba) { + pushIfFeature(pair.b, pair.a, bPos, aPos, pair.ba, false, features); } } } diff --git a/packages/web/src/components/PageComponents/Map/Layers/WaypointLayer.tsx b/packages/web/src/components/PageComponents/Map/Layers/WaypointLayer.tsx index 2bfbe9a1..9c747987 100644 --- a/packages/web/src/components/PageComponents/Map/Layers/WaypointLayer.tsx +++ b/packages/web/src/components/PageComponents/Map/Layers/WaypointLayer.tsx @@ -49,7 +49,7 @@ export const WaypointLayer = ({ return rendered; } - waypoints.forEach((waypoint) => { + for (const waypoint of waypoints) { const [lng, lat] = toLngLat({ latitudeI: waypoint.latitudeI, longitudeI: waypoint.longitudeI, @@ -66,7 +66,7 @@ export const WaypointLayer = ({ onClick={(_, e) => onMarkerClick(waypoint, e)} />, ); - }); + } if (popupState?.type === "waypoint") { const [lng, lat] = toLngLat({ diff --git a/packages/web/src/components/PageComponents/Map/Popups/WaypointDetail.tsx b/packages/web/src/components/PageComponents/Map/Popups/WaypointDetail.tsx index 215b7340..68a1479e 100644 --- a/packages/web/src/components/PageComponents/Map/Popups/WaypointDetail.tsx +++ b/packages/web/src/components/PageComponents/Map/Popups/WaypointDetail.tsx @@ -13,13 +13,11 @@ import { ClockFadingIcon, ClockPlusIcon, CompassIcon, - //Edit3Icon, MapPinnedIcon, MoveHorizontalIcon, NavigationIcon, RotateCwIcon, UserLockIcon, - UserPenIcon, } from "lucide-react"; import { useTranslation } from "react-i18next"; @@ -29,24 +27,7 @@ interface WaypointDetailProps { onEdit: () => void; } -const RowElement: React.FC<{ - label: string; - value: React.ReactNode | string | number | undefined; - icon?: React.ReactNode; -}> = ({ label, value, icon }) => ( -
- - {icon} {label} - - {value} -
-); - -export const WaypointDetail = ({ - waypoint, - myNode, - //onEdit, -}: WaypointDetailProps) => { +export const WaypointDetail = ({ waypoint, myNode }: WaypointDetailProps) => { const { t } = useTranslation("map"); const { getNode } = useNodeDB(); @@ -64,106 +45,147 @@ export const WaypointDetail = ({ : undefined; return ( -
-
-
- {String.fromCodePoint(waypoint.icon) ?? "📍"} +
+
+

+ {String.fromCodePoint(waypoint.icon) ?? "📍"} {waypoint.name} -

-
+ + + {waypoint.description && ( -
- - {waypoint.description} - -
- )} - -
- - - - {t("waypointDetail.longitude")} {t("waypointDetail.latitude")} - - - - {waypointLngLat[0]} {waypointLngLat[1]} - -
- } - icon={} - /> - {waypoint.metadata.updated && ( - } - icon={} - /> - )} - {waypoint.expire !== 0 && ( - } - icon={} - /> +

{waypoint.description}

)} - {distance && ( - } - /> - )} - {bearing && ( - - - {Math.round(bearing)}° - - } - icon={} - /> - )} - } - /> - { - waypoint.lockedTo ? ( - } - /> - ) : null /*( -
- -
- )*/ - } -
+ + + +
+
+ {/* Coordinates */} +
+
+ + + {t("waypointDetail.longitude")} +
+ {t("waypointDetail.latitude")} +
+
+
+ {waypointLngLat[0]} +
+ {waypointLngLat[1]} +
+
+ + {/* Created */} +
+
+ + + {t("waypointDetail.createdDate")} + +
+
+ +
+
+ + {/* Updated */} + {waypoint.metadata.updated && ( +
+
+ + {t("waypointDetail.updated")} +
+
+ +
+
+ )} + + {/* Expires */} + {waypoint.expire !== 0 && ( +
+
+ + {t("waypointDetail.expires")} +
+
+ +
+
+ )} + + {/* Distance */} + {distance != null && ( +
+
+ + {t("waypointDetail.distance")} +
+
+ + {Math.round(distance)}{" "} + {distance === 1 + ? t("unit.meter.one") + : t("unit.meter.plural")} + +
+
+ )} + + {/* Bearing */} + {bearing != null && ( +
+
+ + {t("waypointDetail.bearing")} +
+
+ + {Math.round(bearing)} + {t("unit.degree.suffix")} +
+
+ )} + + {/* Locked To */} + {waypoint.lockedTo && ( +
+
+ + {t("waypointDetail.lockedTo")} +
+
+ {getNode(waypoint.lockedTo)?.user?.longName ?? + t("unknown.longName")} +
+
+ )} +
+
+ ); };