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">
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import type { Project, Stage, Instance, Deploy } from '$lib/types';
import * as api from '$lib/api';
import StatusBadge from '$lib/components/StatusBadge.svelte';
@@ -243,19 +244,23 @@
}
}
let deleted = $state(false);
async function handleDeleteProject() {
showDeleteConfirm = false;
deleted = true;
try {
await api.deleteProject(projectId);
window.location.href = '/projects';
goto('/projects');
} catch (e) {
deleted = false;
error = e instanceof Error ? e.message : $t('projectDetail.deleteFailed');
}
}
$effect(() => {
void projectId;
loadProject();
if (!deleted) loadProject();
});
</script>