Set delayed loading spinner and additional CSP headers

This commit is contained in:
thiloho
2024-09-25 16:02:12 +02:00
parent 0e3c0f094c
commit a9e2bd4cb7
14 changed files with 83 additions and 33 deletions

View File

@@ -10,6 +10,7 @@
const { form, data }: { form: ActionData; data: PageServerData } = $props();
let sending = $state(false);
let loadingDelay: number;
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -30,9 +31,10 @@
method="POST"
action="?/createWebsite"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -120,9 +122,10 @@
method="POST"
action="?/updateWebsite"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update({ reset: false });
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};
@@ -155,9 +158,10 @@
method="POST"
action="?/deleteWebsite"
use:enhance={() => {
sending = true;
loadingDelay = window.setTimeout(() => (sending = true), 500);
return async ({ update }) => {
await update();
window.clearTimeout(loadingDelay);
window.location.hash = "!";
sending = false;
};