diff --git a/web/src/app/discover/discover-client.tsx b/web/src/app/discover/discover-client.tsx index b9cbbf3..6211d96 100644 --- a/web/src/app/discover/discover-client.tsx +++ b/web/src/app/discover/discover-client.tsx @@ -26,6 +26,7 @@ export function DiscoverClient() { const [query, setQuery] = useState(""); const [search, setSearch] = useState(null); const [busy, setBusy] = useState(false); + const [followedSimilar, setFollowedSimilar] = useState>(new Set()); const loadFeed = useCallback(async () => { setFeed(await (await fetch("/api/discover")).json()); @@ -70,6 +71,17 @@ export function DiscoverClient() { } } + async function followSimilar(a: { mbid: string; name: string }) { + const res = await fetch("/api/artists", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ mbid: a.mbid, name: a.name }), + }); + if (res.ok || res.status === 409) { + setFollowedSimilar((s) => new Set(s).add(a.mbid)); + } + } + async function act(id: string, action: "follow" | "want" | "dismiss") { await fetch(`/api/discover/${id}`, { method: "POST", @@ -104,7 +116,13 @@ export function DiscoverClient() { @@ -116,7 +134,11 @@ export function DiscoverClient() {