From b4ece2db85548152510d0e97a90b79ad75065fa9 Mon Sep 17 00:00:00 2001 From: Honey Date: Mon, 8 Jun 2026 23:00:16 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20use=20r.album.sortName=20for=20album=20n?= =?UTF-8?q?ame=20=E2=80=94=20Navidrome=20only=20exposes=20sortName=20on=20?= =?UTF-8?q?album=20objects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Song objects carry sortName for title only, no album/artist sort fields. Album sort is only available on the album object itself (r.album.sortName). Updated loadAlbumDetail to use the fresh API response album, not the nav album. Simplified dispAlbum to not check non-existent song sort fields. Co-Authored-By: Claude Sonnet 4.6 --- src/api.js | 4 ++-- src/views/detail.js | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/api.js b/src/api.js index d19efc3..ceb0789 100644 --- a/src/api.js +++ b/src/api.js @@ -213,12 +213,12 @@ export function dispArtist(s) { if (st && !_isJp(st)) return st; return romajiLookup(s.id)?.artistRomaji || s.artist || ''; } +// Songs don't carry album sort — Navidrome only puts sortName on album objects. +// Check the override list, then return the raw album name. export function dispAlbum(s) { if (!S.cfg.showRomaji) return s.album || ''; const ov = getRomajiOverrides(); if (s.album && ov[s.album]) return ov[s.album]; - const st = s.sortAlbum || s.albumSort; - if (st && !_isJp(st)) return st; return s.album || ''; } // Returns [{name, id}] like parseArtists but with romaji display names when showRomaji is on. diff --git a/src/views/detail.js b/src/views/detail.js index b82ee8c..ed5a2fa 100644 --- a/src/views/detail.js +++ b/src/views/detail.js @@ -1,6 +1,6 @@ import { S } from '../state.js'; import { esc, toast } from '../utils.js'; -import { api, coverUrl, itunesSearch, itunesLookupAlbum, itunesLookupArtistSongs, itunesLookupArtistAlbums, fetchRomajiIndex, dispArtistById, dispAlbumName, dispAlbum, cacheArtistSortNames } from '../api.js'; +import { api, coverUrl, itunesSearch, itunesLookupAlbum, itunesLookupArtistSongs, itunesLookupArtistAlbums, fetchRomajiIndex, dispArtistById, dispAlbumName, cacheArtistSortNames } from '../api.js'; import { makeCard, makeAlbumCard, makeGlobalTrackItem, makeSongItem } from '../ui/components.js'; import { playQueue, dlSongLocal, toggleStar, parseArtists } from '../player/player.js'; import { showCtxMenu, openDlModal } from '../ui/ui.js'; @@ -395,11 +395,9 @@ export async function loadAlbumDetail(album) { const songs = r.album?.song || []; const totalMin = Math.round(songs.reduce((s,t) => s+(t.duration||0), 0) / 60); document.getElementById('album-detail-stats').textContent = `${songs.length} Titel · ${r.album.year||''} · ${totalMin} Min.`; + // r.album has sortName (album sort tag) — use it; nav album may not have sortName + document.getElementById('album-detail-name').textContent = dispAlbumName(r.album); if (songs[0]) { - const s0 = songs[0]; - console.log('[sort-debug] song[0] ALL sort keys:', Object.fromEntries(Object.entries(s0).filter(([k]) => k.toLowerCase().includes('sort')))); - console.log('[sort-debug] r.album ALL sort keys:', Object.fromEntries(Object.entries(r.album).filter(([k]) => k.toLowerCase().includes('sort')))); - document.getElementById('album-detail-name').textContent = dispAlbum(songs[0]) || dispAlbumName(album); artistEl.innerHTML = parseArtists(songs[0]) .map(a => `${esc(dispArtistById(a.id, a.name))}`) .join(' • ') || '';