diff --git a/src/lib/components/git/repositories.svelte b/src/lib/components/git/repositories.svelte index b82781169..39f260a99 100644 --- a/src/lib/components/git/repositories.svelte +++ b/src/lib/components/git/repositories.svelte @@ -23,7 +23,7 @@ import { page } from '$app/state'; import Card from '../card.svelte'; import SkeletonRepoList from './skeletonRepoList.svelte'; - import { untrack } from 'svelte'; + import { onMount, untrack } from 'svelte'; let { action = $bindable('select'), @@ -46,6 +46,11 @@ let search = $state(''); let selectedInstallation = $state(null); let isLoadingRepositories = $state(null); + let installationsMap = $state(null); + + onMount(() => { + loadInstallations(); + }); async function loadInstallations() { if (installationList) { @@ -59,7 +64,7 @@ ) ); } - return installationList.installations; + installationsMap = installationList.installations; } else { const { installations } = await sdk .forProject(page.params.region, page.params.project) @@ -70,7 +75,7 @@ } installation.set(installations.find((entry) => entry.$id === selectedInstallation)); } - return installations; + installationsMap = installations; } } @@ -123,7 +128,7 @@ {#if hasInstallations} - {#await loadInstallations()} + {#if !installationsMap} - {:then installations} + {:else} { + ...installationsMap.map((entry) => { return { label: entry.organization, value: entry.$id @@ -160,7 +165,7 @@ } search = ''; installation.set( - installations.find((entry) => entry.$id === selectedInstallation) + installationsMap.find((entry) => entry.$id === selectedInstallation) ); isLoadingRepositories = true; @@ -174,7 +179,7 @@ bind:value={search} disabled={!search && !$repositories?.repositories?.length} /> - {/await} + {/if} {#if selectedInstallation}