From 43f04e74548fd2794080868479f6782c7492391b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 22 Dec 2025 22:57:02 +0000 Subject: [PATCH] Fix "Invalid Date" display in album details - Backfill album release date from tracks if missing in API response. - Gracefully handle invalid or missing dates in UI rendering. - Fix potential NaN in download folder naming due to invalid dates. --- index.html | 2 +- js/api.js | 14 ++++++++++++++ js/downloads.js | 10 ++++++++-- js/ui.js | 49 +++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index fc7c704..f755577 100644 --- a/index.html +++ b/index.html @@ -138,9 +138,9 @@
-
Album

+
${formatTime(track.duration)}
@@ -66,13 +75,21 @@ export class UIRenderer { createAlbumCardHTML(album) { const explicitBadge = hasExplicitContent(album) ? this.createExplicitBadge() : ''; + let yearDisplay = ''; + if (album.releaseDate) { + const date = new Date(album.releaseDate); + if (!isNaN(date.getTime())) { + yearDisplay = `${date.getFullYear()}`; + } + } return `
${album.title}

${album.title} ${explicitBadge}

-

Album • ${album.artist?.name ?? ''}

+

${album.artist?.name ?? ''}

+

${yearDisplay}

`; } @@ -84,7 +101,6 @@ export class UIRenderer { ${artist.name}

${artist.name}

-

Artist

`; } @@ -109,7 +125,7 @@ export class UIRenderer {
-
+ ${!isArtist ? '
' : ''}
`; } @@ -257,12 +273,14 @@ export class UIRenderer { const imageEl = document.getElementById('album-detail-image'); const titleEl = document.getElementById('album-detail-title'); const metaEl = document.getElementById('album-detail-meta'); + const prodEl = document.getElementById('album-detail-producer'); const tracklistContainer = document.getElementById('album-detail-tracklist'); imageEl.src = ''; imageEl.style.backgroundColor = 'var(--muted)'; titleEl.innerHTML = '
'; metaEl.innerHTML = '
'; + prodEl.innerHTML = '
'; tracklistContainer.innerHTML = `
# @@ -282,15 +300,26 @@ export class UIRenderer { titleEl.innerHTML = `${album.title} ${explicitBadge}`; const totalDuration = calculateTotalDuration(tracks); - const releaseDate = new Date(album.releaseDate); - const year = releaseDate.getFullYear(); + let dateDisplay = ''; + if (album.releaseDate) { + const releaseDate = new Date(album.releaseDate); + if (!isNaN(releaseDate.getTime())) { + const year = releaseDate.getFullYear(); + dateDisplay = window.innerWidth > 768 + ? releaseDate.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) + : year; + } + } - const dateDisplay = window.innerWidth > 768 - ? releaseDate.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) - : year; + const firstCopyright = tracks.find(track => track.copyright)?.copyright; metaEl.innerHTML = - `By ${album.artist.name} • ${dateDisplay} • ${tracks.length} tracks • ${formatDuration(totalDuration)}`; + (dateDisplay ? `${dateDisplay} • ` : '') + + `${tracks.length} tracks • ${formatDuration(totalDuration)}`; + + prodEl.innerHTML = + `By ${album.artist.name}` + + (firstCopyright ? ` • ${firstCopyright}` : ''); tracklistContainer.innerHTML = `