feat: wire detail pages to explore cache for instant hydration
Artist detail page: - Checks exploreCache for pre-loaded artist image (from search) - Checks libraryStore for albums by this artist (by name match) and shows them as discography instantly before API calls - Skips fetchArtistImage if cache already provided one Album detail page: - Checks exploreCache for cached album metadata (title, artist, year) from search results and pre-populates the header - API calls still run to get full data (releases, tracks)
This commit is contained in:
@@ -10,6 +10,7 @@ import type {
|
||||
MBRelease,
|
||||
MBTrack,
|
||||
} from '@go/explore/Service';
|
||||
import { exploreCache } from '../../store/explore-cache';
|
||||
import '@awesome.me/webawesome/dist/components/icon/icon.js';
|
||||
|
||||
/* ── Constants ── */
|
||||
@@ -398,6 +399,21 @@ export class ExploreAlbumDetails extends LitElement {
|
||||
`[explore-album] loading: "${this.albumName}" (${mbid})`,
|
||||
);
|
||||
|
||||
// Phase 0: hydrate from explore cache (instant).
|
||||
const cached = exploreCache.getAlbum(mbid);
|
||||
if (cached) {
|
||||
this.releaseGroup = {
|
||||
mbid: cached.mbid,
|
||||
title: cached.title,
|
||||
artistCredit: cached.artistName,
|
||||
firstReleaseDate: cached.year || '',
|
||||
primaryType: 'Album',
|
||||
} as MBReleaseGroup;
|
||||
this.loadingInfo = false;
|
||||
console.log(`[explore-album] hydrated from cache: "${cached.title}"`);
|
||||
}
|
||||
|
||||
// Phase 1: API calls for full data.
|
||||
const [infoResult, releasesResult] = await Promise.allSettled([
|
||||
this.fetchReleaseGroup(mbid),
|
||||
this.fetchReleases(mbid),
|
||||
|
||||
Reference in New Issue
Block a user