Skip to content

Commit b780bc1

Browse files
cursoragentarmenzg
andcommitted
fix: Prevent unnecessary API calls in useCodeReviewOverviewSection when feature flag is disabled
Add enabled parameter to useCodeReviewOverviewSection hook and pass it through to useInfiniteQuery. This prevents the hook from making API calls to fetch all organization repositories when the seer-overview feature flag is disabled. Co-authored-by: Armen Zambrano G. <armenzg@users.noreply.github.com>
1 parent 714ffe8 commit b780bc1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

static/app/views/settings/seer/overview/codeReviewOverviewSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {useInfiniteQuery, useQueryClient} from 'sentry/utils/queryClient';
2424
import {fetchMutation} from 'sentry/utils/queryClient';
2525
import {useOrganization} from 'sentry/utils/useOrganization';
2626

27-
export function useCodeReviewOverviewSection() {
27+
export function useCodeReviewOverviewSection(enabled = true) {
2828
const organization = useOrganization();
2929

3030
const queryOptions = organizationRepositoriesInfiniteOptions({
@@ -33,6 +33,7 @@ export function useCodeReviewOverviewSection() {
3333
});
3434
const repositoriesResult = useInfiniteQuery({
3535
...queryOptions,
36+
enabled,
3637
select: ({pages}) => {
3738
const repos = uniqBy(
3839
pages.flatMap(page => page.json),

static/gsApp/views/seerAutomation/settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function SeerAutomationSettings() {
4444
const showSeerOverview = organization.features.includes('seer-overview');
4545

4646
const scmOverviewData = useSCMOverviewSection();
47-
const codeReviewOverviewData = useCodeReviewOverviewSection();
47+
const codeReviewOverviewData = useCodeReviewOverviewSection(showSeerOverview);
4848

4949
const orgEndpoint = `/organizations/${organization.slug}/`;
5050
const orgMutationOpts = mutationOptions({

0 commit comments

Comments
 (0)