Skip to content

Commit

Permalink
refactor: Apply same fix to mods + consumables (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelBreslaw authored May 24, 2024
1 parent 4b421b9 commit 722c764
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 69 deletions.
1 change: 0 additions & 1 deletion native/app/inventory/sections/LootItemRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function LootItemRow({ iconData }: Props) {
flexDirection: "row",
justifyContent: "space-between",
alignContent: "space-between",
alignItems: "center",
marginLeft: DEFAULT_MARGIN,
marginRight: DEFAULT_MARGIN,
maxWidth: INV_MAX_WIDTH,
Expand Down
72 changes: 6 additions & 66 deletions native/app/store/AccountInventoryLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
type LostItemsSection,
type SeparatorSection,
type UISections,
type VaultFlexSection,
type VaultSpacerSection,
} from "@/app/inventory/logic/Helpers.ts";
import { getDamageTypeIconUri } from "@/app/inventory/logic/Constants.ts";
Expand Down Expand Up @@ -152,28 +151,20 @@ function buildUIData(get: AccountSliceGetter, sectionBuckets: number[]): UISecti
dataArray.push(separator);

if (bucket === SectionBuckets.Consumables) {
const globalConsumables: VaultFlexSection = {
id: `${bucket}_global_consumables_section`,
type: UISection.VaultFlex,
inventory: [],
};
if (consumables) {
globalConsumables.inventory = returnInventoryArray(consumables, bucket);
const consumableIcons = returnInventoryArray(consumables, bucket);
const lootIconSections = getLootIconSections(consumableIcons, "global_consumables_section");
dataArray.push(...lootIconSections);
}
dataArray.push(globalConsumables);
continue;
}

if (bucket === SectionBuckets.Mods) {
const globalMods: VaultFlexSection = {
id: `${bucket}_global_mods_section`,
type: UISection.VaultFlex,
inventory: [],
};
if (mods) {
globalMods.inventory = returnInventoryArray(mods, bucket);
const modsIcons = returnInventoryArray(mods, bucket);
const lootIconSections = getLootIconSections(modsIcons, "global_mods_section");
dataArray.push(...lootIconSections);
}
dataArray.push(globalMods);
continue;
}

Expand Down Expand Up @@ -276,58 +267,7 @@ function returnVaultUiData(
}

const lootIconSections = getLootIconSections(totalItemsArray, bucket.toString());
// push each section to the dataArray
dataArray.push(...lootIconSections);

// let itemsLeft = totalItemsArray.length;
// let count = 0;
// const needsMinimumSpacer = totalItemsArray.length < 20;
// while (itemsLeft > 0) {
// // is there 21 or more items left?
// if (itemsLeft > 20) {
// const vault5x5Cell: Vault5x5Section = {
// id: `${bucket}_5x5_section${count}`,
// type: UISection.Vault5x5,
// inventory: [],
// };

// const startingPoint = Math.max(0, totalItemsArray.length - itemsLeft);

// const itemsToAdd: DestinyIconData[] = [];
// for (let i = startingPoint; i < startingPoint + 25; i++) {
// const item = totalItemsArray[i];
// if (item) {
// itemsToAdd.push(item);
// } else {
// break;
// }
// }
// vault5x5Cell.inventory = itemsToAdd;
// dataArray.push(vault5x5Cell);
// itemsLeft -= 25;
// count++;
// } else {
// const vaultFlexCell: VaultFlexSection = {
// id: `${bucket}_flex_section`,
// type: UISection.VaultFlex,
// inventory: [],
// minimumSpacerHeight: needsMinimumSpacer ? get().getVaultSpacerSize(bucket) : undefined,
// };

// const startingPoint = Math.max(0, totalItemsArray.length - itemsLeft);

// const itemsToAdd: DestinyIconData[] = [];
// for (let i = startingPoint; i < startingPoint + itemsLeft; i++) {
// const item = totalItemsArray[i];
// if (item) {
// itemsToAdd.push(item);
// }
// }
// vaultFlexCell.inventory = itemsToAdd;
// dataArray.push(vaultFlexCell);
// itemsLeft = 0;
// }
// }
}
}
return dataArray;
Expand Down
4 changes: 2 additions & 2 deletions native/app/store/UIDataSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ function getVaultSpacerSize(get: UIDataSliceGetter, bucket: SectionBuckets): num
if (bucket === SectionBuckets.Consumables) {
const totalConsumables = consumables.length;
const totalRows = Math.ceil(totalConsumables / 5);
return ICON_SIZE * totalRows + ICON_MARGIN * (totalRows - 1);
return (ICON_SIZE + ICON_MARGIN) * totalRows;
}

if (bucket === SectionBuckets.Mods) {
const totalMods = mods.length;
const totalRows = Math.ceil(totalMods / 5);
return ICON_SIZE * totalRows + ICON_MARGIN * (totalRows - 1);
return (ICON_SIZE + ICON_MARGIN) * totalRows;
}
return 0;
}

0 comments on commit 722c764

Please sign in to comment.