Skip to content

Commit

Permalink
fixed imageCollection return value from useAciveRevealResources hook (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pramod-cog authored Jan 31, 2025
1 parent ac47a37 commit c5ac0af
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions react-components/src/hooks/useActiveReveal3dResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export const useActiveReveal3dResources = (
return models.filter((m) => m.visible);
}, [models, layerState]);

const filteredImage360Collections = useMemo(() => {
if (layerState === undefined) {
return EMPTY_ARRAY;
}
return image360Collections.filter((c) => c.getIconsVisibility());
}, [image360Collections, layerState]);

const filteredModelsQuery = useQuery({
queryKey: [
'visible-3d-models',
Expand Down Expand Up @@ -67,22 +74,8 @@ export const useActiveReveal3dResources = (
staleTime: Infinity
});

const filteredImage360CollectionsQuery = useQuery({
queryKey: [
'visible-image360-collections',
image360Collections.map((image360Collection) => `${image360Collection.id}`).sort()
],
queryFn: async () => {
return image360Collections.filter((image360Collection) =>
image360Collection.getIconsVisibility()
);
},
enabled: image360Collections.length > 0,
staleTime: Infinity
});

return {
models: filteredModelsQuery.data ?? EMPTY_ARRAY,
image360Collections: filteredImage360CollectionsQuery.data ?? EMPTY_ARRAY
image360Collections: filteredImage360Collections
};
};

0 comments on commit c5ac0af

Please sign in to comment.