mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix: auto-load repositories when insufficient content in dropdown (#10697)
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Rohit Malhotra <rohitvinodmalhotra@gmail.com>
This commit is contained in:
parent
6eb32e9ae4
commit
c0fa41da65
@ -1,4 +1,4 @@
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useEffect } from "react";
|
||||
import { Provider } from "#/types/settings";
|
||||
import { GitRepository } from "#/types/git";
|
||||
import { useGitRepositories } from "#/hooks/query/use-git-repositories";
|
||||
@ -75,6 +75,35 @@ export function useRepositoryData(
|
||||
inputValue,
|
||||
]);
|
||||
|
||||
// Auto-load more repositories when there aren't enough items to create a scrollable dropdown
|
||||
// This is particularly important for SaaS mode with installations that might have very few repos
|
||||
useEffect(() => {
|
||||
const shouldAutoLoad =
|
||||
!disabled &&
|
||||
!isLoading &&
|
||||
!isFetchingNextPage &&
|
||||
!isSearchLoading &&
|
||||
hasNextPage &&
|
||||
!processedSearchInput && // Not during search (use all repos, not search results)
|
||||
urlSearchResults.length === 0 &&
|
||||
repositories.length > 0 && // Have some repositories loaded
|
||||
repositories.length < 10; // But not enough to create a scrollable dropdown
|
||||
|
||||
if (shouldAutoLoad) {
|
||||
fetchNextPage();
|
||||
}
|
||||
}, [
|
||||
disabled,
|
||||
isLoading,
|
||||
isFetchingNextPage,
|
||||
isSearchLoading,
|
||||
hasNextPage,
|
||||
processedSearchInput,
|
||||
urlSearchResults.length,
|
||||
repositories.length,
|
||||
fetchNextPage,
|
||||
]);
|
||||
|
||||
return {
|
||||
repositories,
|
||||
allRepositories,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user