fix: album cards use romaji index for album name display via _albumRomajiMap

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-06-06 01:10:38 +02:00
1 parent 52f5385988
commit 45cb62198e
2 files changed
+12 -4

No files matched your search

+8 -3
View File
@@ -69,18 +69,22 @@ export async function ndAuth() {
// ─── ROMAJI INDEX ───
// Fetched once per session from the backend, cached in memory.
let _romajiIndex = null;
let _romajiMap = null; // Map<songId, { titleRomaji, artistRomaji, albumRomaji }>
let _romajiMap = null; // Map<songId, { titleRomaji, artistRomaji, albumRomaji }>
let _artistRomajiMap = null; // Map<artistId, artistRomaji>
let _albumRomajiMap = null; // Map<albumName(JP), albumRomaji> — for album cards without song ID
let _romajiIndexFetch = null; // in-flight promise dedup
function _buildRomajiMap(idx) {
const m = new Map();
const am = new Map();
const bm = new Map();
if (Array.isArray(idx)) idx.forEach(e => {
m.set(String(e.id), e);
if (e.artistId && e.artistRomaji) am.set(String(e.artistId), e.artistRomaji);
if (e.album && e.albumRomaji && !bm.has(e.album)) bm.set(e.album, e.albumRomaji);
});
_artistRomajiMap = am;
_albumRomajiMap = bm;
return m;
}
@@ -96,7 +100,7 @@ export async function fetchRomajiIndex() {
return _romajiIndexFetch;
}
export function invalidateRomajiIndex() { _romajiIndex = null; _romajiMap = null; _artistRomajiMap = null; }
export function invalidateRomajiIndex() { _romajiIndex = null; _romajiMap = null; _artistRomajiMap = null; _albumRomajiMap = null; }
// ─── ROMAJI OVERRIDES ───
// Stored server-side (shared across all clients). Cached in memory per session.
@@ -144,7 +148,8 @@ export function dispArtistById(id, name) {
export function dispAlbumName(name) {
if (!S.cfg.showRomaji) return name || '';
const ov = getRomajiOverrides();
return ov[name] || name || '';
if (name && ov[name]) return ov[name];
return _albumRomajiMap?.get(name) || name || '';
}
// Synchronous lookup — returns index entry for a song ID, or null if not in index.