fix(library): show album cover art in the Albums grid
The album cards always fell back to the 💿 placeholder: the mapper dropped the backend's `has_cover` and no album cover URL was ever built. Carry `hasCover` through `RawAlbum`/`Album` and add `getAlbumCoverUrl` (GET /albums/{id}/cover, token in the query like the track/stream URLs). The Library Albums grid and the artist-detail discography now render real covers, same source the album-detail page already used. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ import {
|
||||
} from '../../store/selectors/localLibrary';
|
||||
import { setQueue } from '../../store/slices/queue';
|
||||
import type { Track, Album, Artist } from '../../api/types';
|
||||
import { getCoverUrl } from '../../api/endpoints/streaming';
|
||||
import { getCoverUrl, getAlbumCoverUrl } from '../../api/endpoints/streaming';
|
||||
import { formatDuration } from '../../lib/format';
|
||||
import { useDebounce } from 'use-debounce';
|
||||
|
||||
@@ -300,7 +300,12 @@ export function LibraryPage() {
|
||||
|
||||
function AlbumCard({ album, onClick }: { album: Album; onClick: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
const artUrl = getCoverUrl(album.artUrl);
|
||||
const token = useAppSelector((s) => s.auth.accessToken);
|
||||
// The album record has no cover URL; build one from `hasCover` (served by
|
||||
// GET /albums/{id}/cover, token in the query — <img> can't send a header).
|
||||
const artUrl =
|
||||
getCoverUrl(album.artUrl) ??
|
||||
(token ? getAlbumCoverUrl(album.id, token, album.hasCover) : undefined);
|
||||
return (
|
||||
<Card
|
||||
onClick={onClick}
|
||||
|
||||
Reference in New Issue
Block a user