From a8c1600111631028b072b0238c35e85b7935b66c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Jul 2026 23:43:30 +0200 Subject: [PATCH] fix(discover): dismissing an artist also dismisses its albums Co-Authored-By: Claude Opus 4.8 (1M context) --- web/src/app/api/discover/[id]/route.test.ts | 14 ++++++++++++++ web/src/app/api/discover/[id]/route.ts | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/web/src/app/api/discover/[id]/route.test.ts b/web/src/app/api/discover/[id]/route.test.ts index 7b24d7e..70283c8 100644 --- a/web/src/app/api/discover/[id]/route.test.ts +++ b/web/src/app/api/discover/[id]/route.test.ts @@ -63,6 +63,20 @@ describe("discover action API", () => { expect((await prisma.discoverySuggestion.findUnique({ where: { id: s.id } }))!.status).toBe("followed"); }); + it("dismissing an artist also dismisses its pending album suggestions", async () => { + const a = await prisma.discoverySuggestion.create({ + data: { kind: "artist", artistMbid: "shared", artistName: "Cand", score: 1, seedCount: 1, + sources: ["listenbrainz"], secondaryTypes: [], dedupeKey: "artist:shared:" }, + }); + const alb = await prisma.discoverySuggestion.create({ + data: { kind: "album", artistMbid: "shared", artistName: "Cand", rgMbid: "rgS", album: "Rec", + albumReason: "newest", score: 1, seedCount: 1, sources: ["listenbrainz"], + secondaryTypes: [], dedupeKey: "album:shared:rgS" }, + }); + await post(a.id, { action: "dismiss" }); + expect((await prisma.discoverySuggestion.findUnique({ where: { id: alb.id } }))!.status).toBe("dismissed"); + }); + it("want upserts a monitored release from the suggestion and marks wanted", async () => { const s = await album("rgW"); const res = await post(s.id, { action: "want" }); diff --git a/web/src/app/api/discover/[id]/route.ts b/web/src/app/api/discover/[id]/route.ts index 3240bcf..0c0c22e 100644 --- a/web/src/app/api/discover/[id]/route.ts +++ b/web/src/app/api/discover/[id]/route.ts @@ -19,6 +19,14 @@ export async function POST(request: Request, { params }: { params: Promise<{ id: if (action === "dismiss") { await prisma.discoverySuggestion.update({ where: { id }, data: { status: "dismissed" } }); + // Dismissing an artist also dismisses its album suggestions, so the whole unified row + // disappears cleanly instead of leaving the artist's albums stranded. + if (s.kind === "artist") { + await prisma.discoverySuggestion.updateMany({ + where: { kind: "album", artistMbid: s.artistMbid, status: "pending" }, + data: { status: "dismissed" }, + }); + } return Response.json({ id, status: "dismissed" }); }