This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
listSources,
|
||||
type GiteaCommit
|
||||
} from './application-api';
|
||||
import { getStoredSelectedComponentId, setStoredSelectedComponentId } from '../../lib/selected-app';
|
||||
|
||||
const giteaBaseUrl = import.meta.env.VITE_GITEA_BASE_URL ?? 'http://localhost:3000';
|
||||
const giteaAppOrg = import.meta.env.VITE_GITEA_APP_ORG ?? import.meta.env.GITEA_APP_ORG ?? 'platform';
|
||||
@@ -341,8 +342,15 @@ export function SourceManagementPage() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedSourceId((current) => filteredSources.some((source) => source.id === current) ? current : filteredSources[0]?.id ?? '');
|
||||
}, [filteredSources]);
|
||||
setSelectedSourceId((current) => {
|
||||
if (filteredSources.some((source) => source.id === current)) return current;
|
||||
|
||||
const storedSourceId = getStoredSelectedComponentId(selectedAppId);
|
||||
const nextSource = filteredSources.find((source) => source.id === storedSourceId) ?? filteredSources[0];
|
||||
if (nextSource?.id) setStoredSelectedComponentId(selectedAppId, nextSource.id);
|
||||
return nextSource?.id ?? '';
|
||||
});
|
||||
}, [filteredSources, selectedAppId]);
|
||||
|
||||
useEffect(() => {
|
||||
setCommitPage(1);
|
||||
@@ -431,7 +439,11 @@ export function SourceManagementPage() {
|
||||
<select
|
||||
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring"
|
||||
value={selectedSource?.id ?? ''}
|
||||
onChange={(event) => setSelectedSourceId(event.target.value)}
|
||||
onChange={(event) => {
|
||||
const nextSourceId = event.target.value;
|
||||
setSelectedSourceId(nextSourceId);
|
||||
setStoredSelectedComponentId(selectedAppId, nextSourceId);
|
||||
}}
|
||||
disabled={filteredSources.length === 0}
|
||||
>
|
||||
{filteredSources.map((source) => (
|
||||
|
||||
Reference in New Issue
Block a user