Skip to content

Commit

Permalink
Fix bug: "Asset Group list view shows entire catalog" (#23792)
Browse files Browse the repository at this point in the history
## Summary & Motivation
As titled.

The cause of this was an effect fetching all assets instead of using the
`groupSelector` on initial load.

## How I Tested These Changes

loaded the list view for a group and made sure we filtered correctly.
  • Loading branch information
salazarm authored Aug 21, 2024
1 parent 00e2305 commit a7319f7
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export function useAllAssets({
),
});

const fetchAssets = useCallback(async () => {
const allAssetsQuery = useCallback(async () => {
if (groupSelector) {
return;
}
try {
const data = await fetchPaginatedData({
async fetchData(cursor: string | null | undefined) {
Expand Down Expand Up @@ -134,11 +137,7 @@ export function useAllAssets({
}));
}
}
}, [batchLimit, cacheManager, client]);

useEffect(() => {
fetchAssets();
}, [fetchAssets]);
}, [batchLimit, cacheManager, client, groupSelector]);

const groupQuery = useCallback(async () => {
if (!groupSelector) {
Expand Down Expand Up @@ -166,14 +165,20 @@ export function useAllAssets({
onData(data);
}, [groupSelector, client]);

const query = groupSelector ? groupQuery : allAssetsQuery;

useEffect(() => {
query();
}, [query]);

return useMemo(() => {
return {
assets,
error,
loading: !assets && !error,
query: groupSelector ? groupQuery : fetchAssets,
query,
};
}, [assets, error, fetchAssets, groupQuery, groupSelector]);
}, [assets, error, query]);
}

interface AssetCatalogTableProps {
Expand Down

1 comment on commit a7319f7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-dvdekheru-elementl.vercel.app

Built with commit a7319f7.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.