fix: prevent error flash on project delete by using SPA navigation and blocking re-fetch

This commit is contained in:
2026-04-05 13:51:37 +03:00
parent 5577851f22
commit 198bdb856c
+7 -2
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'; import { page } from '$app/stores';
import { goto } from '$app/navigation';
import type { Project, Stage, Instance, Deploy } from '$lib/types'; import type { Project, Stage, Instance, Deploy } from '$lib/types';
import * as api from '$lib/api'; import * as api from '$lib/api';
import StatusBadge from '$lib/components/StatusBadge.svelte'; import StatusBadge from '$lib/components/StatusBadge.svelte';
@@ -243,19 +244,23 @@
} }
} }
let deleted = $state(false);
async function handleDeleteProject() { async function handleDeleteProject() {
showDeleteConfirm = false; showDeleteConfirm = false;
deleted = true;
try { try {
await api.deleteProject(projectId); await api.deleteProject(projectId);
window.location.href = '/projects'; goto('/projects');
} catch (e) { } catch (e) {
deleted = false;
error = e instanceof Error ? e.message : $t('projectDetail.deleteFailed'); error = e instanceof Error ? e.message : $t('projectDetail.deleteFailed');
} }
} }
$effect(() => { $effect(() => {
void projectId; void projectId;
loadProject(); if (!deleted) loadProject();
}); });
</script> </script>