api + web: pull album art on first view, not first CDJ load#22
Merged
Conversation
Newly added tracks showed no artwork in the web UI until a CDJ loaded them. The add path only reads the tag-embedded picture, which misses art ffmpeg can see, and the artwork endpoint's lazy extraction (one probe on first request, then cached for good) was unreachable from the UI: every render site gated the <img> on art_id > 0, so the request that would have triggered extraction was never made. Loading the track on a deck ran analysis, whose artwork write-back set art_id, and only then did the UI show art - a chicken-and-egg the CDJ happened to break. The track payload now carries art_checked, and a shared artHTML helper renders the <img> optimistically whenever the file has never been probed: the first view of a new track fires the artwork request, the endpoint extracts synchronously, and the same response delivers the image. Tracks probed and found artless go straight to the placeholder (no repeated 404 traffic) and an onerror fallback covers the artless and concurrent-probe cases. Verified in the browser against a fresh library: a never-probed track with embedded art shows it on first open of the detail drawer with art_id and art_checked persisted, an artless track degrades to the placeholder, and after its probe it makes no further artwork requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Newly added tracks showed no artwork in the web UI until a CDJ loaded them. The add path only reads the tag-embedded picture, which misses art ffmpeg can see, and the artwork endpoint's lazy extraction (one probe on first request, then cached for good) was unreachable from the UI: every render site gated the img on art_id > 0, so the request that would have triggered extraction was never made. Loading the track on a deck ran analysis, whose artwork write-back set art_id, and only then did the UI show art, a chicken-and-egg the CDJ happened to break.
The track payload now carries art_checked (the server-side "has this file ever been probed" flag), and a shared artHTML helper, replacing three copy-pasted render sites (table ART column, mobile card, detail drawer), renders the img optimistically whenever the file has never been probed: the first view of a new track fires the artwork request, the endpoint extracts synchronously, and the same response delivers the image. Tracks probed and found artless go straight to the placeholder, so there is no repeated 404 traffic, and an onerror fallback covers the artless and concurrent-probe cases.
Verified in the browser against a fresh library: a never-probed track with embedded art shows it on first open of the detail drawer with art_id and art_checked persisted behind it, an artless track degrades to the placeholder, and after its probe it makes no further artwork requests across a reload.
Hardware testing
Checklist
go build ./...,go vet ./..., andgo test ./...passgofmt -l .is cleanGPL-3.0-or-later) (n/a, no new files)