Skip to content

Commit

Permalink
fix(performance): Switch custom useQuery to useApiQuery (#76403)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed Aug 26, 2024
1 parent 2d0ea92 commit e882947
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const setupMockRequests = (
},
});
MockApiClient.addMockResponse({
url: `/api/0/projects/org-slug/project-slug/performance/configure/`,
url: `/projects/org-slug/project-slug/performance/configure/`,
method: 'GET',
body: {
enable_images: enableImages,
Expand Down
18 changes: 8 additions & 10 deletions static/app/views/performance/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import {TRACING_FIELDS} from 'sentry/utils/discover/fields';
import {SavedQueryDatasets} from 'sentry/utils/discover/types';
import {statsPeriodToDays} from 'sentry/utils/duration/statsPeriodToDays';
import getCurrentSentryReactRootSpan from 'sentry/utils/getCurrentSentryReactRootSpan';
import {useQuery} from 'sentry/utils/queryClient';
import {useApiQuery} from 'sentry/utils/queryClient';
import {decodeScalar} from 'sentry/utils/queryString';
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import useApi from 'sentry/utils/useApi';
import useOrganization from 'sentry/utils/useOrganization';
import useProjects from 'sentry/utils/useProjects';
import {hasDatasetSelector} from 'sentry/views/dashboards/utils';
Expand Down Expand Up @@ -379,17 +378,16 @@ export function getProjectID(
}

export function usePerformanceGeneralProjectSettings(projectId?: number) {
const api = useApi();
const organization = useOrganization();
const {projects} = useProjects();
const stringProjectId = projectId?.toString();
const project = projects.find(p => p.id === stringProjectId);

return useQuery(['settings', 'general', projectId], {
enabled: Boolean(project),
queryFn: () =>
api.requestPromise(
`/api/0/projects/${organization.slug}/${project?.slug}/performance/configure/`
) as Promise<{enable_images: boolean}>,
});
return useApiQuery<{enable_images: boolean}>(
[`/projects/${organization.slug}/${project?.slug}/performance/configure/`],
{
staleTime: 0,
enabled: Boolean(project),
}
);
}

0 comments on commit e882947

Please sign in to comment.