fix: invalidate sort caches after metadata save, remove sort-debug logs
After saving sort tags via the metadata editor, invalidate _artistSortMap and the apiCached getArtists entry so the updated Navidrome sortName values are picked up on the next page visit without a hard refresh. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
85f8d758a5
commit
59adee60d5
3 files changed
+4
-6
No files matched your search
+1
-3
@@ -133,12 +133,10 @@ export async function ensureArtistSortMap() {
|
|||||||
_artistSortFetch = apiCached('getArtists')
|
_artistSortFetch = apiCached('getArtists')
|
||||||
.then(r => {
|
.then(r => {
|
||||||
const all = (r?.artists?.index || []).flatMap(i => i.artist || []);
|
const all = (r?.artists?.index || []).flatMap(i => i.artist || []);
|
||||||
console.log('[sort-debug] getArtists sample (first 3):', all.slice(0,3).map(a => ({ id: a.id, name: a.name, sortName: a.sortName })));
|
|
||||||
cacheArtistSortNames(all);
|
cacheArtistSortNames(all);
|
||||||
console.log('[sort-debug] _artistSortMap size:', _artistSortMap?.size);
|
|
||||||
_artistSortFetch = null;
|
_artistSortFetch = null;
|
||||||
})
|
})
|
||||||
.catch(e => { console.warn('[sort-debug] ensureArtistSortMap error:', e); _artistSortFetch = null; });
|
.catch(e => { console.warn('ensureArtistSortMap error:', e); _artistSortFetch = null; });
|
||||||
return _artistSortFetch;
|
return _artistSortFetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,6 @@
|
|||||||
import { S } from '../state.js';
|
import { S } from '../state.js';
|
||||||
import { esc, formatDur, toast } from '../utils.js';
|
import { esc, formatDur, toast } from '../utils.js';
|
||||||
import { api, coverUrl, fetchRomajiIndex, romajiLookup, getRomajiOverrides } from '../api.js';
|
import { api, coverUrl, fetchRomajiIndex, romajiLookup, getRomajiOverrides, invalidateRomajiIndex, invalidateApiCache } from '../api.js';
|
||||||
// Circular — safe (only used inside function bodies)
|
// Circular — safe (only used inside function bodies)
|
||||||
import { loadPlaylists, loadPlaylistDetail } from '../views/views.js';
|
import { loadPlaylists, loadPlaylistDetail } from '../views/views.js';
|
||||||
import { showConfirm } from './modals.js';
|
import { showConfirm } from './modals.js';
|
||||||
@@ -270,6 +270,8 @@ export async function saveMetadata() {
|
|||||||
if (!r.ok) throw new Error(d.error || `HTTP ${r.status}`);
|
if (!r.ok) throw new Error(d.error || `HTTP ${r.status}`);
|
||||||
status.textContent = '✅ Gespeichert! Navidrome scannt…';
|
status.textContent = '✅ Gespeichert! Navidrome scannt…';
|
||||||
toast('✅ Metadaten gespeichert');
|
toast('✅ Metadaten gespeichert');
|
||||||
|
invalidateRomajiIndex();
|
||||||
|
invalidateApiCache('getArtists');
|
||||||
setTimeout(() => { _leaveEditMode(); closeInfoModal(); }, 1500);
|
setTimeout(() => { _leaveEditMode(); closeInfoModal(); }, 1500);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
status.textContent = '❌ Fehler: ' + e.message;
|
status.textContent = '❌ Fehler: ' + e.message;
|
||||||
|
|||||||
@@ -396,8 +396,6 @@ 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.`;
|
||||||
console.log('[sort-debug] r.album full:', JSON.stringify(r.album));
|
|
||||||
if (songs[0]) console.log('[sort-debug] songs[0] full:', JSON.stringify(songs[0]));
|
|
||||||
// r.album has sortName (album sort tag) — use it; nav album may not have sortName
|
// r.album has sortName (album sort tag) — use it; nav album may not have sortName
|
||||||
document.getElementById('album-detail-name').textContent = dispAlbumName(r.album);
|
document.getElementById('album-detail-name').textContent = dispAlbumName(r.album);
|
||||||
if (songs[0]) {
|
if (songs[0]) {
|
||||||
|
|||||||
Reference in new issue
Block a user