mirror of
https://lavaforge.org/spotizerr/spotizerr.git
synced 2025-12-24 02:39:14 -05:00
feat: Reimplement download artist discography per groups in artist page
This commit is contained in:
@@ -343,6 +343,25 @@ export const Artist = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDownloadGroup = async (group: "album" | "single" | "compilation" | "appears_on") => {
|
||||
if (!artistId || !artist) return;
|
||||
try {
|
||||
toast.info(`Queueing ${group} downloads for ${artist.name}...`);
|
||||
const response = await apiClient.get(`/artist/download/${artistId}?album_type=${group}`);
|
||||
const count = response.data?.queued_albums?.length ?? 0;
|
||||
if (count > 0) {
|
||||
toast.success(`Queued ${count} ${group}${count > 1 ? "s" : ""}.`);
|
||||
} else {
|
||||
toast.info(`No new ${group} releases to download.`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(`Failed to queue ${group} downloads:`, error);
|
||||
toast.error(`Failed to queue ${group} downloads`, {
|
||||
description: error.response?.data?.error || "An unexpected error occurred.",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleWatch = async () => {
|
||||
if (!artistId || !artist) return;
|
||||
try {
|
||||
@@ -493,7 +512,17 @@ export const Artist = () => {
|
||||
{/* Albums */}
|
||||
{artistAlbums.length > 0 && (
|
||||
<div className="mb-12">
|
||||
<h2 className="text-3xl font-bold mb-6 text-content-primary dark:text-content-primary-dark">Albums</h2>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h2 className="text-3xl font-bold text-content-primary dark:text-content-primary-dark">Albums</h2>
|
||||
<button
|
||||
onClick={() => handleDownloadGroup("album")}
|
||||
className="flex items-center gap-2 px-3 py-1.5 text-sm bg-button-success hover:bg-button-success-hover text-button-success-text rounded-md transition-colors"
|
||||
title="Download all albums"
|
||||
>
|
||||
<img src="/download.svg" alt="Download" className="w-4 h-4 logo" />
|
||||
<span>Download</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-6">
|
||||
{artistAlbums.map((album) => (
|
||||
<AlbumCard key={album.id} album={album} onDownload={() => handleDownloadAlbum(album)} />
|
||||
@@ -505,7 +534,17 @@ export const Artist = () => {
|
||||
{/* Singles */}
|
||||
{artistSingles.length > 0 && (
|
||||
<div className="mb-12">
|
||||
<h2 className="text-3xl font-bold mb-6 text-content-primary dark:text-content-primary-dark">Singles</h2>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h2 className="text-3xl font-bold text-content-primary dark:text-content-primary-dark">Singles</h2>
|
||||
<button
|
||||
onClick={() => handleDownloadGroup("single")}
|
||||
className="flex items-center gap-2 px-3 py-1.5 text-sm bg-button-success hover:bg-button-success-hover text-button-success-text rounded-md transition-colors"
|
||||
title="Download all singles"
|
||||
>
|
||||
<img src="/download.svg" alt="Download" className="w-4 h-4 logo" />
|
||||
<span>Download</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-6">
|
||||
{artistSingles.map((album) => (
|
||||
<AlbumCard key={album.id} album={album} onDownload={() => handleDownloadAlbum(album)} />
|
||||
@@ -517,7 +556,17 @@ export const Artist = () => {
|
||||
{/* Compilations */}
|
||||
{artistCompilations.length > 0 && (
|
||||
<div className="mb-12">
|
||||
<h2 className="text-3xl font-bold mb-6 text-content-primary dark:text-content-primary-dark">Compilations</h2>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h2 className="text-3xl font-bold text-content-primary dark:text-content-primary-dark">Compilations</h2>
|
||||
<button
|
||||
onClick={() => handleDownloadGroup("compilation")}
|
||||
className="flex items-center gap-2 px-3 py-1.5 text-sm bg-button-success hover:bg-button-success-hover text-button-success-text rounded-md transition-colors"
|
||||
title="Download all compilations"
|
||||
>
|
||||
<img src="/download.svg" alt="Download" className="w-4 h-4 logo" />
|
||||
<span>Download</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-6">
|
||||
{artistCompilations.map((album) => (
|
||||
<AlbumCard key={album.id} album={album} onDownload={() => handleDownloadAlbum(album)} />
|
||||
@@ -529,7 +578,17 @@ export const Artist = () => {
|
||||
{/* Appears On */}
|
||||
{artistAppearsOn.length > 0 && (
|
||||
<div className="mb-12">
|
||||
<h2 className="text-3xl font-bold mb-6 text-content-primary dark:text-content-primary-dark">Appears On</h2>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h2 className="text-3xl font-bold text-content-primary dark:text-content-primary-dark">Appears On</h2>
|
||||
<button
|
||||
onClick={() => handleDownloadGroup("appears_on")}
|
||||
className="flex items-center gap-2 px-3 py-1.5 text-sm bg-button-success hover:bg-button-success-hover text-button-success-text rounded-md transition-colors"
|
||||
title="Download all appears on"
|
||||
>
|
||||
<img src="/download.svg" alt="Download" className="w-4 h-4 logo" />
|
||||
<span>Download</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-6">
|
||||
{artistAppearsOn.map((album) => (
|
||||
<AlbumCard key={album.id} album={album} onDownload={() => handleDownloadAlbum(album)} />
|
||||
|
||||
Reference in New Issue
Block a user