feat(pwa): Schreib-Aktionen zeigen Offline-Toast statt stillem Fail
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m18s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m18s
Neuer Helper requireOnline(action) prüft vor jedem Schreib-Fetch
den Online-Status. Offline: ein Toast erscheint ("Die Aktion braucht
eine Internet-Verbindung."), Aktion bricht sauber ab. Der Button-
State bleibt unverändert (kein optimistisches Update, das gleich
wieder zurückgedreht werden müsste).
Eingebaut in Rezept-Detail (8 Handler), Register (2), Wunschliste
(2), Admin Domains/Profile/Backup, Home-Dismiss.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { Pencil, Check, X, Globe } from 'lucide-svelte';
|
||||
import type { AllowedDomain } from '$lib/types';
|
||||
import { confirmAction, alertAction } from '$lib/client/confirm.svelte';
|
||||
import { requireOnline } from '$lib/client/require-online';
|
||||
|
||||
let domains = $state<AllowedDomain[]>([]);
|
||||
let loading = $state(true);
|
||||
@@ -25,6 +26,7 @@
|
||||
async function add() {
|
||||
errored = null;
|
||||
if (!newDomain.trim()) return;
|
||||
if (!requireOnline('Das Hinzufügen')) return;
|
||||
adding = true;
|
||||
const res = await fetch('/api/domains', {
|
||||
method: 'POST',
|
||||
@@ -59,6 +61,7 @@
|
||||
|
||||
async function saveEdit(d: AllowedDomain) {
|
||||
if (!editDomain.trim()) return;
|
||||
if (!requireOnline('Das Speichern')) return;
|
||||
saving = true;
|
||||
try {
|
||||
const res = await fetch(`/api/domains/${d.id}`, {
|
||||
@@ -92,6 +95,7 @@
|
||||
destructive: true
|
||||
});
|
||||
if (!ok) return;
|
||||
if (!requireOnline('Das Entfernen')) return;
|
||||
await fetch(`/api/domains/${d.id}`, { method: 'DELETE' });
|
||||
await load();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user