UX safety: confirm destructive deletes, scope dice clear, back up sessionLog, add 404

- New themed useConfirm() hook (no native dialogs). World deletes (notes, quests,
  homebrew, maps) now confirm before removing.
- Dice 'Clear history' is disabled with no active campaign (it used to wipe EVERY
  campaign's rolls) and now confirms; only ever clears the active campaign.
- sessionLog is included in backup/restore and the campaign cascade-delete — it was
  silently dropped on backup and orphaned on campaign delete.
- Unknown URLs render a themed 'Page not found' with a link home instead of a blank shell.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 17:37:52 +02:00
parent 3e39e44a8a
commit f2e4259c84
10 changed files with 99 additions and 11 deletions
+4 -1
View File
@@ -7,6 +7,7 @@ import { useNotes } from './hooks';
import { Page, PageHeader, EmptyState, RequireCampaign } from '@/components/ui/Page';
import { Button } from '@/components/ui/Button';
import { Input } from '@/components/ui/Input';
import { useConfirm } from '@/components/ui/useConfirm';
import { cn } from '@/lib/cn';
export function NotesPage() {
@@ -98,6 +99,7 @@ function NoteEditor({
const [title, setTitle] = useState(note.title);
const [body, setBody] = useState(note.body);
const [tags, setTags] = useState(note.tags.join(', '));
const { confirm, confirmElement } = useConfirm();
// Save the full snapshot so editing title + body quickly doesn't drop an edit.
const save = useDebouncedCallback((next: { title: string; body: string; tags: string }) => {
@@ -127,11 +129,12 @@ function NoteEditor({
<Button
variant="ghost"
className="text-danger"
onClick={async () => { await notesRepo.remove(note.id); onSelect(null); }}
onClick={async () => { if (await confirm({ title: 'Delete note?', message: <>Delete <strong className="text-ink">{title || 'this note'}</strong>? This cant be undone.</> })) { await notesRepo.remove(note.id); onSelect(null); } }}
>
Delete
</Button>
</div>
{confirmElement}
<label className="mb-3 block text-xs text-muted">
Tags (comma-separated)