diff --git a/ui/src/routes/discover/+page.svelte b/ui/src/routes/discover/+page.svelte index 935be27..342c7f6 100644 --- a/ui/src/routes/discover/+page.svelte +++ b/ui/src/routes/discover/+page.svelte @@ -239,6 +239,16 @@ body: JSON.stringify({ slug: book.slug, action }) }); + // Optimistically add/update the history list so the drawer shows it immediately. + // If this slug was already voted (e.g. swiped twice via undo+re-swipe), replace it. + const existing = votedBooks.findIndex((v) => v.slug === book.slug); + const entry: VotedBook = { slug: book.slug, action, votedAt: new Date().toISOString(), book }; + if (existing !== -1) { + votedBooks = [entry, ...votedBooks.filter((_, i) => i !== existing)]; + } else { + votedBooks = [entry, ...votedBooks]; + } + // Fly out transitioning = true; const target = flyTargets[action];