From faba8fcbd543e134bea6397b68cf97132d5a08d5 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 4 Nov 2024 12:48:42 -0800 Subject: [PATCH] Fix collectibles --- src/app/records/presentation-nodes.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/records/presentation-nodes.ts b/src/app/records/presentation-nodes.ts index 27f089303d..c8cbf10151 100644 --- a/src/app/records/presentation-nodes.ts +++ b/src/app/records/presentation-nodes.ts @@ -28,6 +28,7 @@ import { DestinyRecordState, DestinyScope, } from 'bungie-api-ts/destiny2'; +import { minBy } from 'es-toolkit'; import { unlockedItemsForCharacterOrProfilePlugSet } from './plugset-helpers'; export interface DimPresentationNodeLeaf { @@ -597,11 +598,13 @@ export function getCollectibleState( ) { return collectibleDef.scope === DestinyScope.Character ? profileResponse.characterCollectibles?.data - ? // Find the version of the collectible that's unlocked, if any - Object.values(profileResponse.characterCollectibles.data).find( - (c) => - (c.collectibles[collectibleDef.hash].state ?? 0) & DestinyCollectibleState.NotAcquired, - )?.collectibles[collectibleDef.hash].state + ? minBy( + // Find the version of the collectible that's unlocked, if any + Object.values(profileResponse.characterCollectibles.data) + .map((c) => c.collectibles[collectibleDef.hash].state) + .filter((s) => s !== undefined), + (state) => state & DestinyCollectibleState.NotAcquired, + ) : undefined : profileResponse.profileCollectibles?.data?.collectibles[collectibleDef.hash]?.state; }