fix: dispArtistById prefers Navidrome sortName over kuromoji translation
Added _artistSortMap populated from getArtists (artist listing) and getArtist (artist detail) responses. dispArtistById now checks the Navidrome sort tag first, falls back to kuromoji only when missing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
da68afe0e0
commit
4c3ec5726c
3 files changed
+21
-6
No files matched your search
+14
-2
@@ -91,7 +91,8 @@ export async function ndAuth() {
|
||||
// Fetched once per session from the backend, cached in memory.
|
||||
let _romajiIndex = null;
|
||||
let _romajiMap = null; // Map<songId, { titleRomaji, artistRomaji, albumRomaji }>
|
||||
let _artistRomajiMap = null; // Map<artistId, artistRomaji>
|
||||
let _artistRomajiMap = null; // Map<artistId, artistRomaji> — kuromoji backend
|
||||
let _artistSortMap = null; // Map<artistId, sortName> — Navidrome sort tag (preferred)
|
||||
let _albumRomajiMap = null; // Map<albumName(JP), albumRomaji> — for album cards without song ID
|
||||
let _romajiIndexFetch = null; // in-flight promise dedup
|
||||
|
||||
@@ -121,7 +122,16 @@ export async function fetchRomajiIndex() {
|
||||
return _romajiIndexFetch;
|
||||
}
|
||||
|
||||
export function invalidateRomajiIndex() { _romajiIndex = null; _romajiMap = null; _artistRomajiMap = null; _albumRomajiMap = null; }
|
||||
export function invalidateRomajiIndex() { _romajiIndex = null; _romajiMap = null; _artistRomajiMap = null; _artistSortMap = null; _albumRomajiMap = null; }
|
||||
|
||||
// Populate _artistSortMap from Navidrome artist objects (OpenSubsonic sortName field).
|
||||
// Called whenever getArtists or getArtist data is loaded so dispArtistById can use it.
|
||||
export function cacheArtistSortNames(artists) {
|
||||
if (!_artistSortMap) _artistSortMap = new Map();
|
||||
for (const a of artists) {
|
||||
if (a.id && a.sortName && !_isJp(a.sortName)) _artistSortMap.set(String(a.id), a.sortName);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── ROMAJI OVERRIDES ───
|
||||
// Stored server-side (shared across all clients). Cached in memory per session.
|
||||
@@ -164,6 +174,8 @@ export function dispArtistById(id, name) {
|
||||
if (!S.cfg.showRomaji) return name || '';
|
||||
const ov = getRomajiOverrides();
|
||||
if (name && ov[name]) return ov[name];
|
||||
const sort = _artistSortMap?.get(String(id));
|
||||
if (sort) return sort;
|
||||
return _artistRomajiMap?.get(String(id)) || name || '';
|
||||
}
|
||||
export function dispAlbumName(name) {
|
||||
|
||||
Reference in new issue
Block a user