Skip to content

Commit

Permalink
Fix collectibles
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed Nov 4, 2024
1 parent bff01d3 commit faba8fc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/app/records/presentation-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit faba8fc

Please sign in to comment.