fix: use r.album.sortName for album name — Navidrome only exposes sortName on album objects

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 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-06-08 23:00:16 +02:00
1 parent 228f58d6d5
commit b4ece2db85
2 files changed
+5 -7

No files matched your search

+2 -2
View File
@@ -213,12 +213,12 @@ export function dispArtist(s) {
if (st && !_isJp(st)) return st; if (st && !_isJp(st)) return st;
return romajiLookup(s.id)?.artistRomaji || s.artist || ''; 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) { export function dispAlbum(s) {
if (!S.cfg.showRomaji) return s.album || ''; if (!S.cfg.showRomaji) return s.album || '';
const ov = getRomajiOverrides(); const ov = getRomajiOverrides();
if (s.album && ov[s.album]) return ov[s.album]; 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 || ''; return s.album || '';
} }
// Returns [{name, id}] like parseArtists but with romaji display names when showRomaji is on. // Returns [{name, id}] like parseArtists but with romaji display names when showRomaji is on.
+3 -5
View File
@@ -1,6 +1,6 @@
import { S } from '../state.js'; import { S } from '../state.js';
import { esc, toast } from '../utils.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 { makeCard, makeAlbumCard, makeGlobalTrackItem, makeSongItem } from '../ui/components.js';
import { playQueue, dlSongLocal, toggleStar, parseArtists } from '../player/player.js'; import { playQueue, dlSongLocal, toggleStar, parseArtists } from '../player/player.js';
import { showCtxMenu, openDlModal } from '../ui/ui.js'; import { showCtxMenu, openDlModal } from '../ui/ui.js';
@@ -395,11 +395,9 @@ export async function loadAlbumDetail(album) {
const songs = r.album?.song || []; const songs = r.album?.song || [];
const totalMin = Math.round(songs.reduce((s,t) => s+(t.duration||0), 0) / 60); 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.`; 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]) { 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]) artistEl.innerHTML = parseArtists(songs[0])
.map(a => `<span class="song-link" onclick="event.stopPropagation();s_goArtist(event,'${esc(a.originalName||a.name)}','${esc(a.id||'')}')">${esc(dispArtistById(a.id, a.name))}</span>`) .map(a => `<span class="song-link" onclick="event.stopPropagation();s_goArtist(event,'${esc(a.originalName||a.name)}','${esc(a.id||'')}')">${esc(dispArtistById(a.id, a.name))}</span>`)
.join('<span style="color:var(--text3)"> • </span>') || ''; .join('<span style="color:var(--text3)"> • </span>') || '';