diff --git a/src/views/detail.js b/src/views/detail.js index 052ec3d..809fe05 100644 --- a/src/views/detail.js +++ b/src/views/detail.js @@ -86,16 +86,21 @@ export async function loadArtistDetail(artist) { const hasND = !!artist.id; const knownItunes = artist.itunesArtistId || null; - const [imgRes, albumRes, infoRes, topRes, iArtistRes, eventsRes] = await Promise.allSettled([ - hasND ? getArtistImage(artist.id) : Promise.resolve(null), - hasND ? api('getArtist', `&id=${artist.id}`) : Promise.resolve(null), - hasND ? api('getArtistInfo2',`&id=${artist.id}&count=8`) : Promise.resolve(null), - hasND ? api('getTopSongs', `&artist=${encodeURIComponent(artist.name)}&count=10`) : Promise.resolve(null), - knownItunes - ? Promise.resolve([{ artistId: knownItunes }]) - : itunesSearch(artist.name, 'musicArtist', 5), - fetchEvents(artist.name), - ]); + // Fire all requests immediately so they run in parallel. + // Hero only needs imgP + albumP (both fast / usually cached) — await those + // first so the hero appears instantly without waiting for iTunes or events. + const imgP = hasND ? getArtistImage(artist.id) : Promise.resolve(null); + const albumP = hasND ? api('getArtist', `&id=${artist.id}`) : Promise.resolve(null); + const infoP = hasND ? api('getArtistInfo2',`&id=${artist.id}&count=8`) : Promise.resolve(null); + const topP = hasND ? api('getTopSongs', `&artist=${encodeURIComponent(artist.name)}&count=10`) : Promise.resolve(null); + const iArtistP = knownItunes ? Promise.resolve([{ artistId: knownItunes }]) : itunesSearch(artist.name, 'musicArtist', 5); + const eventsP = fetchEvents(artist.name); + + // Phase 1 — hero (fast: image usually cached from listing, getArtist is local) + const [imgRes, albumRes] = await Promise.allSettled([imgP, albumP]); + + // Phase 2 — content (may be slow: Last.fm bio, iTunes, events) + const [infoRes, topRes, iArtistRes, eventsRes] = await Promise.allSettled([infoP, topP, iArtistP, eventsP]); const _normWords = s => new Set((s || '').toLowerCase().replace(/[^a-z0-9]/g, ' ').split(/\s+/).filter(Boolean)); const _queryWords = _normWords(artist.name);