fix: prevent error flash on project delete by using SPA navigation and blocking re-fetch
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user