Skip to content

Commit 1cda642

Browse files
committed
fixed bug in neighbor lines when self node has no location.
1 parent eb5a204 commit 1cda642

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/pages/Map/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,26 @@ const generateNeighborLines = (
9090
};
9191
};
9292
const generateDirectLines = (nodes: Protobuf.Mesh.NodeInfo[]) => {
93-
const features = [];
93+
const selfNode = nodes.find((n) => n.isFavorite);
94+
const features: {
95+
type: string;
96+
geometry: {
97+
type: string;
98+
coordinates: number[][];
99+
};
100+
properties: {
101+
color: string;
102+
};
103+
}[] = [];
104+
105+
if (!selfNode || !selfNode.position)
106+
return { type: "FeatureCollection", features };
107+
94108
for (const node of nodes) {
95109
if (!node.position) continue;
96110
if (node.hopsAway > 0) continue;
97111
if (Date.now() / 1000 - node.lastHeard > DIRECT_NODE_TIMEOUT) continue;
98112
const start = convertToLatLng(node.position);
99-
const selfNode = nodes.find((n) => n.isFavorite);
100113
const end = convertToLatLng(selfNode.position);
101114
features.push({
102115
type: "Feature",

0 commit comments

Comments
 (0)