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

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:
hsiegeln
2026-04-18 16:54:03 +02:00
parent 447ff2be32
commit 3906781c4e
7 changed files with 35 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import { profileStore } from '$lib/client/profile.svelte';
import { confirmAction, alertAction } from '$lib/client/confirm.svelte';
import { requireOnline } from '$lib/client/require-online';
let newName = $state('');
let newEmoji = $state('🍳');
@@ -10,6 +11,7 @@
async function add() {
errored = null;
if (!newName.trim()) return;
if (!requireOnline('Das Anlegen')) return;
adding = true;
try {
await profileStore.create(newName.trim(), newEmoji || null);
@@ -24,6 +26,7 @@
async function rename(id: number, currentName: string) {
const next = prompt('Neuer Name:', currentName);
if (!next || next === currentName) return;
if (!requireOnline('Das Umbenennen')) return;
const res = await fetch(`/api/profiles/${id}`, {
method: 'PATCH',
headers: { 'content-type': 'application/json' },
@@ -49,6 +52,7 @@
destructive: true
});
if (!ok) return;
if (!requireOnline('Das Löschen')) return;
await fetch(`/api/profiles/${id}`, { method: 'DELETE' });
if (profileStore.activeId === id) profileStore.clear();
await profileStore.load();