fix: artist images

This commit is contained in:
Xoconoch
2025-08-30 07:27:13 -06:00
parent 5942e6ea36
commit 3ff6134712
3 changed files with 10 additions and 5 deletions

View File

@@ -93,7 +93,7 @@ export const Artist = () => {
setArtist(data); setArtist(data);
// Lazy-load banner image after render // Lazy-load banner image after render
const allImages = [...(data.portrait_group ?? []), ...(data.biography?.portrait_group ?? [])]; const allImages = [...(data.portrait_group.image ?? []), ...(data.biography?.[0].portrait_group.image ?? [])];
const candidateBanner = allImages const candidateBanner = allImages
.filter(img => img && typeof img === 'object' && 'url' in img) .filter(img => img && typeof img === 'object' && 'url' in img)
.sort((a, b) => (b.width ?? 0) - (a.width ?? 0))[0]?.url || "/placeholder.jpg"; .sort((a, b) => (b.width ?? 0) - (a.width ?? 0))[0]?.url || "/placeholder.jpg";

View File

@@ -176,7 +176,7 @@ export const Watchlist = () => {
<img <img
src={ src={
item.itemType === "artist" item.itemType === "artist"
? (item as WatchedArtist).portrait_group[0]?.url || "/images/placeholder.jpg" ? (item as WatchedArtist).portrait_group.image[0].url || "/images/placeholder.jpg"
: (item as WatchedPlaylist).picture || "/images/placeholder.jpg" : (item as WatchedPlaylist).picture || "/images/placeholder.jpg"
} }
alt={item.name} alt={item.name}

View File

@@ -20,21 +20,26 @@ export interface LibrespotArtistStub {
export interface LibrespotBiographyType { export interface LibrespotBiographyType {
text: string; text: string;
portrait_group: LibrespotImage[]; portrait_group: LibrespotArtistImageType;
} }
export interface LibrespotTopTrackType { export interface LibrespotTopTrackType {
country: string; country: string;
track: string[]; track: string[];
} }
export interface LibrespotArtistImageType {
image: LibrespotImage[];
}
// Full artist object (get_artist) // Full artist object (get_artist)
export interface LibrespotArtistType { export interface LibrespotArtistType {
id: string; id: string;
name: string; name: string;
top_track: LibrespotTopTrackType[]; top_track: LibrespotTopTrackType[];
portrait_group: LibrespotImage[]; portrait_group: LibrespotArtistImageType;
popularity: number; popularity: number;
biography: LibrespotBiographyType; biography?: LibrespotBiographyType[];
album_group?: string[]; album_group?: string[];
single_group?: string[]; single_group?: string[];
compilation_group?: string[]; compilation_group?: string[];