feat(web): refresh the current view after deleting a song or playlist

Deletes left the removed item visible because the list loaders are cached (getPlaylists
~3 min): deletePlaylist navigated to a still-cached list, and deleteSong only reloaded
playlists. Add refreshCurrentView() — drops the API cache and re-runs the active nav
entry's loader (playlists, playlist/album/artist detail, starred, home, …). deleteSong
calls it after the delete+rescan delay; deletePlaylist invalidates getPlaylists before
navigating. Bump SW cache to ns-v46.

Also record the post-1.2 work in the 1.2 changelog (importer Enter, search single-song
+ radio, NowPlaying order, official-audio artist-metadata match, JP-katakana album
artist fix, year back-fill, delete refresh).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Opus 4.8 committed 2026-07-26 23:27:29 +02:00
1 parent 966b318d9e
commit d98978a6c7
5 files changed
+36 -8

No files matched your search

+4 -6
View File
@@ -2,7 +2,7 @@ import { S } from '../state.js';
import { esc, formatDur, toast } from '../utils.js';
import { api, coverUrl, fetchRomajiIndex, romajiLookup, getRomajiOverrides, invalidateRomajiIndex, invalidateApiCache } from '../api.js';
// Circular — safe (only used inside function bodies)
import { loadPlaylists, loadPlaylistDetail } from '../views/views.js';
import { loadPlaylists, loadPlaylistDetail, refreshCurrentView } from '../views/views.js';
import { showConfirm } from './modals.js';
// ─── SONG INFO MODAL ───
@@ -312,11 +312,9 @@ export async function deleteSong() {
if (!r.ok) throw new Error(d.error || `HTTP ${r.status}`);
toast(`🗑 "${s.title}" gelöscht`);
closeInfoModal();
setTimeout(() => {
loadPlaylists();
if (document.getElementById('page-playlist-detail')?.classList.contains('active') && S._currentPlaylist)
loadPlaylistDetail(S._currentPlaylist);
}, 3000);
// Backend delete + Navidrome rescan takes a moment; then refresh whatever view is open (album,
// artist, playlist, starred, …) so the removed song disappears without a manual reload.
setTimeout(() => refreshCurrentView(), 3000);
} catch (e) {
status.textContent = '❌ Fehler: ' + e.message;
}