mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 08:03:15 +00:00
fix repo dropdown selection (#388)
This commit is contained in:
parent
3f4576b24b
commit
0f5bb868d9
1 changed files with 24 additions and 9 deletions
|
|
@ -135,6 +135,9 @@ export function useGitHubApp(): UseGitHubAppReturn {
|
||||||
// Track if we've attempted to load from localStorage
|
// Track if we've attempted to load from localStorage
|
||||||
const hasCheckedLocalStorageRef = useRef(false);
|
const hasCheckedLocalStorageRef = useRef(false);
|
||||||
|
|
||||||
|
// Track previous installation ID to detect actual changes
|
||||||
|
const previousInstallationIdRef = useRef<string | null>(null);
|
||||||
|
|
||||||
const selectedRepository = useMemo(() => {
|
const selectedRepository = useMemo(() => {
|
||||||
if (!selectedRepositoryParam) return null;
|
if (!selectedRepositoryParam) return null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -294,21 +297,33 @@ export function useGitHubApp(): UseGitHubAppReturn {
|
||||||
// Refresh repositories when installation changes
|
// Refresh repositories when installation changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentInstallationId) {
|
if (currentInstallationId) {
|
||||||
// Clear selected repository and branches when installation changes
|
const previousInstallationId = previousInstallationIdRef.current;
|
||||||
setSelectedRepository(null);
|
|
||||||
setBranches([]);
|
|
||||||
setRepositoriesPage(1);
|
|
||||||
setRepositoriesHasMore(false);
|
|
||||||
|
|
||||||
// Reset auto-selection flags so they can run again for the new installation
|
// Only clear repository if installation actually changed to a different value
|
||||||
hasAutoSelectedRef.current = false;
|
if (
|
||||||
hasCheckedLocalStorageRef.current = false;
|
previousInstallationId !== null &&
|
||||||
|
previousInstallationId !== currentInstallationId
|
||||||
|
) {
|
||||||
|
// Clear selected repository and branches when installation changes
|
||||||
|
setSelectedRepository(null);
|
||||||
|
setBranches([]);
|
||||||
|
setRepositoriesPage(1);
|
||||||
|
setRepositoriesHasMore(false);
|
||||||
|
|
||||||
// Fetch repositories for the new installation
|
// Reset auto-selection flags so they can run again for the new installation
|
||||||
|
hasAutoSelectedRef.current = false;
|
||||||
|
hasCheckedLocalStorageRef.current = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the previous installation ID reference
|
||||||
|
previousInstallationIdRef.current = currentInstallationId;
|
||||||
|
|
||||||
|
// Fetch repositories for the current installation
|
||||||
checkInstallation();
|
checkInstallation();
|
||||||
}
|
}
|
||||||
}, [currentInstallationId]);
|
}, [currentInstallationId]);
|
||||||
|
|
||||||
|
// Check localStorage for previously selected repository
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
!hasCheckedLocalStorageRef.current &&
|
!hasCheckedLocalStorageRef.current &&
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue