CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 11s
CI / federation-interop (push) Successful in 1m37s
CI / test (push) Successful in 3m24s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 6s
- art.js revoked each thumbnail's blob: URL on its own "load" event, but the same URL is shared (via the lookup cache) by every thumbnail for that album on the page - revoking after the first one loaded broke every other <img> still using it. Stop revoking; this is a full-page-reload site, so the browser releases the memory on navigation anyway. - .ranking-art/.log-art thumbnails inherited their row's default cross-axis alignment (baseline for .ranking, stretch for .log), which suits text but left the art sitting high against two-line name+artist text. Center them explicitly instead. Verified in-browser across all four surfaces (song page hero, dashboard Albums ranking, Recently played, History) with real MusicBrainz/Cover Art Archive artwork. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
// A small thumbnail that starts as a placeholder and swaps itself for the real album art
|
|
// once (if) it resolves. Shared by every list/page that shows art.
|
|
|
|
import { fetchImage } from "./api.js";
|
|
import { h } from "./dom.js";
|
|
|
|
const cache = new Map(); // dedupes repeat/concurrent lookups for the same album within a page
|
|
|
|
export function artThumb(artist, album, extraClass) {
|
|
const classes = extraClass ? `art-thumb ${extraClass}` : "art-thumb";
|
|
const el = h("div", { class: `${classes} art-thumb-empty` });
|
|
if (!album) return el; // nothing to look up
|
|
|
|
const key = `${artist.toLowerCase()}␟${album.toLowerCase()}`;
|
|
if (!cache.has(key)) {
|
|
cache.set(
|
|
key,
|
|
fetchImage(`/art/album?artist=${encodeURIComponent(artist)}&album=${encodeURIComponent(album)}`),
|
|
);
|
|
}
|
|
cache.get(key).then((url) => {
|
|
if (!url) return; // miss or failed fetch: leave the placeholder
|
|
// Not revoked: the same URL is shared by every thumbnail for this album on the page
|
|
// (see `cache` above), and this is a full-page-reload site, so the browser releases it
|
|
// on navigation anyway.
|
|
const img = h("img", { class: classes, alt: "", loading: "lazy" });
|
|
img.src = url;
|
|
el.replaceWith(img);
|
|
});
|
|
return el;
|
|
}
|