-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
ref(repos): Replace useOrganizationRepositories with calls to useInfiniteQuery and useFetchAllPages #112880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(repos): Replace useOrganizationRepositories with calls to useInfiniteQuery and useFetchAllPages #112880
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import {Fragment, useCallback, useMemo, useRef, useState, type ChangeEvent} from 'react'; | ||
| import styled from '@emotion/styled'; | ||
| import {useInfiniteQuery} from '@tanstack/react-query'; | ||
| import {useVirtualizer} from '@tanstack/react-virtual'; | ||
|
|
||
| import {Alert} from '@sentry/scraps/alert'; | ||
|
|
@@ -9,10 +10,11 @@ import {Flex, Stack} from '@sentry/scraps/layout'; | |
| import {Link} from '@sentry/scraps/link'; | ||
|
|
||
| import type {ModalRenderProps} from 'sentry/actionCreators/modal'; | ||
| import {useOrganizationRepositories} from 'sentry/components/events/autofix/preferences/hooks/useOrganizationRepositories'; | ||
| import {LoadingIndicator} from 'sentry/components/loadingIndicator'; | ||
| import {IconSearch} from 'sentry/icons'; | ||
| import {t, tct, tn} from 'sentry/locale'; | ||
| import {useFetchAllPages} from 'sentry/utils/api/apiFetch'; | ||
| import {organizationRepositoriesInfiniteOptions} from 'sentry/utils/repositories/repoQueryOptions'; | ||
| import {useOrganization} from 'sentry/utils/useOrganization'; | ||
| import {MAX_REPOS_LIMIT} from 'sentry/views/settings/projectSeer/constants'; | ||
|
|
||
|
|
@@ -37,10 +39,14 @@ export function AddAutofixRepoModal({ | |
| Footer, | ||
| closeModal, | ||
| }: Props) { | ||
| const {data: repositories, isFetching: isFetchingRepositories} = | ||
| useOrganizationRepositories(); | ||
|
|
||
| const organization = useOrganization(); | ||
| const result = useInfiniteQuery({ | ||
| ...organizationRepositoriesInfiniteOptions({organization}), | ||
| select: ({pages}) => pages.flatMap(page => page.json), | ||
| }); | ||
| useFetchAllPages({result}); | ||
| const {data: repositories, isFetching: isFetchingRepositories} = result; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Loading state flickers between sequential page fetchesMedium Severity Using Additional Locations (2)Reviewed by Cursor Bugbot for commit 5502bfa. Configure here. |
||
|
|
||
| const [modalSearchQuery, setModalSearchQuery] = useState(''); | ||
| const [showMaxLimitAlert, setShowMaxLimitAlert] = useState(false); | ||
| const [modalSelectedRepoIds, setModalSelectedRepoIds] = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import {useCallback, useEffect, useMemo, useState} from 'react'; | ||
| import {useTheme} from '@emotion/react'; | ||
| import styled from '@emotion/styled'; | ||
| import {useInfiniteQuery} from '@tanstack/react-query'; | ||
|
|
||
| import {Alert} from '@sentry/scraps/alert'; | ||
| import {Button} from '@sentry/scraps/button'; | ||
|
|
@@ -10,7 +11,6 @@ import {Tooltip} from '@sentry/scraps/tooltip'; | |
|
|
||
| import {openModal} from 'sentry/actionCreators/modal'; | ||
| import {DropdownMenu} from 'sentry/components/dropdownMenu'; | ||
| import {useOrganizationRepositories} from 'sentry/components/events/autofix/preferences/hooks/useOrganizationRepositories'; | ||
| import {useProjectSeerPreferences} from 'sentry/components/events/autofix/preferences/hooks/useProjectSeerPreferences'; | ||
| import {useUpdateProjectSeerPreferences} from 'sentry/components/events/autofix/preferences/hooks/useUpdateProjectSeerPreferences'; | ||
| import type { | ||
|
|
@@ -25,6 +25,8 @@ import {IconAdd} from 'sentry/icons'; | |
| import {t, tct} from 'sentry/locale'; | ||
| import {PluginIcon} from 'sentry/plugins/components/pluginIcon'; | ||
| import type {Project} from 'sentry/types/project'; | ||
| import {useFetchAllPages} from 'sentry/utils/api/apiFetch'; | ||
| import {organizationRepositoriesInfiniteOptions} from 'sentry/utils/repositories/repoQueryOptions'; | ||
| import {useOrganization} from 'sentry/utils/useOrganization'; | ||
|
|
||
| import {AddAutofixRepoModal} from './addAutofixRepoModal'; | ||
|
|
@@ -38,8 +40,12 @@ interface ProjectSeerProps { | |
| export function AutofixRepositories({project}: ProjectSeerProps) { | ||
| const theme = useTheme(); | ||
| const organization = useOrganization(); | ||
| const {data: repositories, isFetching: isFetchingRepositories} = | ||
| useOrganizationRepositories(); | ||
| const result = useInfiniteQuery({ | ||
| ...organizationRepositoriesInfiniteOptions({organization}), | ||
| select: ({pages}) => pages.flatMap(page => page.json), | ||
| }); | ||
| useFetchAllPages({result}); | ||
| const {data: repositories, isFetching: isFetchingRepositories} = result; | ||
|
Comment on lines
+43
to
+48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The component doesn't handle the Suggested FixIn both Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| const { | ||
| preference, | ||
| codeMappingRepos, | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deduplication of repositories by externalId removed
Low Severity
The deleted
useOrganizationRepositorieshook deduplicated repositories byexternalId, keeping only the first occurrence and filtering out repos without anexternalId. The replacementselect: ({pages}) => pages.flatMap(page => page.json)does plain flattening with no deduplication. If the API returns repos sharing the sameexternalId(e.g., connected through multiple integrations), downstream code that keys onexternalIdfor selection, settings, and filtering could display duplicates or behave unexpectedly.Additional Locations (1)
static/app/views/settings/projectSeer/autofixRepositories.tsx#L44-L45Reviewed by Cursor Bugbot for commit 5502bfa. Configure here.