Skip to content

Commit

Permalink
don't try to fetch metadatas until we have all uris
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuripetusko committed Mar 13, 2024
1 parent 08ddec7 commit a4005a9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/rmrk-hooks/src/lib/hooks/use-get-composed-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,35 @@ export const useGetComposedState = (
slotParts,
] = equippableDataResponse || [];

const fixedMetadataUris = fixedParts?.map((p) => p.metadataURI);

const {
isLoading: isLoadingFixedPartsMetadatas,
isError: isErrorFixedPartsMetadatas,
isFetching: isFetchingFixedPartsMetadatas,
data: fixedPartsWithMetadatas,
} = useFetchMetadataAndAddToEntities(
{
metadataUris: fixedParts?.map((p) => p.metadataURI),
metadataUris: fixedMetadataUris,
},
{ enabled: enabled && enabledMetadataFetch },
{ enabled: enabled && enabledMetadataFetch && !!fixedMetadataUris },
fixedParts?.map((p) => ({ z: p.z })),
);

const slotMetadataUris = slotParts?.map(
(p) => p.childAssetMetadata || p.partMetadata,
);

const {
isLoading: isLoadingSlotPartsMetadatas,
isError: isErrorSlotPartsMetadatas,
isFetching: isFetchingSlotPartsMetadatas,
data: slotPartsWithMetadatas,
} = useFetchMetadataAndAddToEntities(
{
metadataUris: slotParts?.map(
(p) => p.childAssetMetadata || p.partMetadata,
),
metadataUris: slotMetadataUris,
},
{ enabled: enabled && enabledMetadataFetch },
{ enabled: enabled && enabledMetadataFetch && !!slotMetadataUris },
slotParts?.map((p) => ({ z: p.z })),
);

Expand Down

0 comments on commit a4005a9

Please sign in to comment.