Skip to content

Commit a9c8cf1

Browse files
committed
fix(types): handle edge case for empty mounted vehicle parts
1 parent d613f4e commit a9c8cf1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/types/VehicleView.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,21 @@ const zForPart = (partId: string): number => {
4949
};
5050
5151
const { minX, maxX, minY, maxY, finalGrid } = (() => {
52+
const mountedParts = normalizeVehicleMountedParts(item);
53+
if (mountedParts.length === 0) {
54+
return {
55+
minX: 0,
56+
maxX: 0,
57+
minY: 0,
58+
maxY: 0,
59+
finalGrid: [] as (VehicleMountedPartDefinition | undefined)[][],
60+
};
61+
}
62+
5263
let minX = Infinity;
5364
let maxX = -Infinity;
5465
let minY = Infinity;
5566
let maxY = -Infinity;
56-
57-
const mountedParts = normalizeVehicleMountedParts(item);
5867
for (const part of mountedParts) {
5968
if (part.x < minX) minX = part.x;
6069
if (part.x > maxX) maxX = part.x;

0 commit comments

Comments
 (0)