From c98fa1d907e8fa55e37bcf4c15ab57e5b245f73e Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sun, 12 May 2024 16:53:36 +0200 Subject: [PATCH] chore: ShipSnapshotSlotsType was not consistent in its type (#118) --- src/FormatAsEft/FormatAsEft.tsx | 4 ++-- src/HardwareListing/HardwareListing.tsx | 6 +++--- src/ShipSnapshotProvider/ShipSnapshotProvider.tsx | 11 +++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/FormatAsEft/FormatAsEft.tsx b/src/FormatAsEft/FormatAsEft.tsx index 4ceadb2..6e4fa49 100644 --- a/src/FormatAsEft/FormatAsEft.tsx +++ b/src/FormatAsEft/FormatAsEft.tsx @@ -4,7 +4,7 @@ import { EveDataContext } from "../EveDataProvider"; import { ShipSnapshotContext, ShipSnapshotSlotsType } from "../ShipSnapshotProvider"; /** Mapping between slot types and ESI flags (for first slot in the type). */ -const esiFlagMapping: Record = { +const esiFlagMapping: Record = { lowslot: [11, 12, 13, 14, 15, 16, 17, 18], medslot: [19, 20, 21, 22, 23, 24, 25, 26], hislot: [27, 28, 29, 30, 31, 32, 33, 34], @@ -14,7 +14,7 @@ const esiFlagMapping: Record = { }; /** Mapping between slot-type and the EFT string name. */ -const slotToEft: Record = { +const slotToEft: Record = { lowslot: "Low Slot", medslot: "Mid Slot", hislot: "High Slot", diff --git a/src/HardwareListing/HardwareListing.tsx b/src/HardwareListing/HardwareListing.tsx index b85166e..0c62082 100644 --- a/src/HardwareListing/HardwareListing.tsx +++ b/src/HardwareListing/HardwareListing.tsx @@ -20,7 +20,7 @@ interface ListingItem { name: string; meta: number; typeId: number; - slotType: ShipSnapshotSlotsType | "dronebay" | "charge"; + slotType: ShipSnapshotSlotsType | "charge"; } interface ListingGroup { @@ -202,7 +202,7 @@ export const HardwareListing = () => { if (module.marketGroupID === undefined) continue; if (!module.published) continue; - let slotType: ShipSnapshotSlotsType | "dronebay" | "charge" | undefined; + let slotType: ShipSnapshotSlotsType | "charge" | undefined; if (module.categoryID !== 8) { slotType = eveData.typeDogma?.[typeId]?.dogmaEffects .map((effect) => { @@ -221,7 +221,7 @@ export const HardwareListing = () => { }) .filter((slot) => slot !== undefined)[0]; if (module.categoryID === 18) { - slotType = "dronebay"; + slotType = "droneBay"; } if (slotType === undefined) continue; diff --git a/src/ShipSnapshotProvider/ShipSnapshotProvider.tsx b/src/ShipSnapshotProvider/ShipSnapshotProvider.tsx index eb346a4..a5b2a89 100644 --- a/src/ShipSnapshotProvider/ShipSnapshotProvider.tsx +++ b/src/ShipSnapshotProvider/ShipSnapshotProvider.tsx @@ -53,7 +53,7 @@ interface ShipSnapshotSlots { turret: number; } -export type ShipSnapshotSlotsType = keyof ShipSnapshotSlots; +export type ShipSnapshotSlotsType = "hislot" | "medslot" | "lowslot" | "subsystem" | "rig" | "droneBay"; interface ShipSnapshot { loaded?: boolean; @@ -70,7 +70,7 @@ interface ShipSnapshot { currentFit?: EsiFit; currentSkills?: Record; - addModule: (typeId: number, slot: ShipSnapshotSlotsType | "dronebay") => void; + addModule: (typeId: number, slot: ShipSnapshotSlotsType) => void; removeModule: (flag: number) => void; addCharge: (chargeTypeId: number) => void; removeCharge: (flag: number) => void; @@ -113,8 +113,7 @@ const slotStart: Record = { lowslot: 11, subsystem: 125, rig: 92, - launcher: 27, - turret: 27, + droneBay: 87, }; export interface ShipSnapshotProps { @@ -191,14 +190,14 @@ export const ShipSnapshotProvider = (props: ShipSnapshotProps) => { }, []); const addModule = React.useCallback( - (typeId: number, slot: ShipSnapshotSlotsType | "dronebay") => { + (typeId: number, slot: ShipSnapshotSlotsType) => { setCurrentFit((oldFit: EsiFit | undefined) => { if (oldFit === undefined) return undefined; let flag = 0; /* Find the first free slot for that slot-type. */ - if (slot !== "dronebay") { + if (slot !== "droneBay") { for (let i = slotStart[slot]; i < slotStart[slot] + shipSnapshot.slots[slot]; i++) { if (oldFit.items.find((item) => item.flag === i) !== undefined) continue;