fix(web): surface a toast on failed mutations (#14)
Several client mutations either ignored a non-ok response (silent no-op) or toasted success unconditionally even when the request failed. Sweep them so every mutation gives feedback: - artists: toggle auto-monitor, unfollow → error toast on failure. - discography + wanted: toggle monitor / search-now → success or error toast. - discover suggestion follow/want/dismiss → error toast (was toasting success even on failure). - The Floor: queue request + retry → error toast on failure. - artist-modal + preview follow/want, Last.fm want → error toast on failure (closes the deferred "want() shows no toast on non-ok" item). web 153 tests, tsc + build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+12
-6
@@ -76,22 +76,28 @@ export function Queue() {
|
||||
}, []);
|
||||
|
||||
async function retry(id: string) {
|
||||
const res = await fetch(`/api/requests/${id}/retry`, { method: "POST" });
|
||||
if (res.ok) {
|
||||
toast("Retrying…");
|
||||
refresh();
|
||||
const res = await fetch(`/api/requests/${id}/retry`, { method: "POST" }).catch(() => null);
|
||||
if (!res?.ok) {
|
||||
toast("Couldn't retry");
|
||||
return;
|
||||
}
|
||||
toast("Retrying…");
|
||||
refresh();
|
||||
}
|
||||
|
||||
async function submit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!artist.trim() || !album.trim()) return;
|
||||
const label = album.trim();
|
||||
await fetch("/api/requests", {
|
||||
const res = await fetch("/api/requests", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ artist, album }),
|
||||
});
|
||||
}).catch(() => null);
|
||||
if (!res?.ok) {
|
||||
toast(`Couldn't queue ${label}`);
|
||||
return;
|
||||
}
|
||||
toast(`Queued ${label}`);
|
||||
setArtist("");
|
||||
setAlbum("");
|
||||
|
||||
Reference in New Issue
Block a user