Skip to content

Commit f7bf98c

Browse files
narsaynorathandrewshie-sentry
authored andcommitted
fix(dashboards): Invalidate starred query data using correct queryKey (#94925)
The helper does a feature flag check to invalidate the correct key since the URLs are different. Fixes the scenario where the sidebar is in its dynamic state, you rearrange, and when you hover out and back onto the dashboards list, the dashboards should be in the new order. They were in the old order because we didn't invalidate the cache with the new query key. After the feature flag gets removed I'll just hardcode the query key instead of exporting it/getting it through the helper
1 parent c25b0f3 commit f7bf98c

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

static/app/views/dashboards/hooks/useGetStarredDashboards.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {useApiQuery} from 'sentry/utils/queryClient';
44
import useOrganization from 'sentry/utils/useOrganization';
55
import type {DashboardListItem} from 'sentry/views/dashboards/types';
66

7-
function getQueryKey(organization: Organization): ApiQueryKey {
7+
export function getQueryKey(organization: Organization): ApiQueryKey {
88
const DASHBOARDS_QUERY_KEY = [
99
`/organizations/${organization.slug}/dashboards/`,
1010
{

static/app/views/dashboards/hooks/useInvalidateStarredDashboards.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@ import {useCallback} from 'react';
22

33
import {useQueryClient} from 'sentry/utils/queryClient';
44
import useOrganization from 'sentry/utils/useOrganization';
5+
import {getQueryKey} from 'sentry/views/dashboards/hooks/useGetStarredDashboards';
56

67
export function useInvalidateStarredDashboards() {
78
const organization = useOrganization();
89
const queryClient = useQueryClient();
910

1011
return useCallback(() => {
11-
queryClient.invalidateQueries({
12-
queryKey: [
13-
`/organizations/${organization.slug}/dashboards/`,
14-
{query: {filter: 'onlyFavorites'}},
15-
],
16-
});
17-
}, [queryClient, organization.slug]);
12+
queryClient.invalidateQueries({queryKey: getQueryKey(organization)});
13+
}, [queryClient, organization]);
1814
}

0 commit comments

Comments
 (0)