fix: download notification opened the wrong song (same-name album)

The finished-download notification resolved the album by name via search3, then fell back to
a same-named album by a DIFFERENT artist (or the first result) when the exact artist match
wasn't found — e.g. right after download, before Navidrome rescans. Many artists share an album
title ("I LIKE IT!"), so the notification navigated to a completely different song.

- Web (notify.js) + Android (AppNavigation): require the artist to match when known (fuzzy for
  multi-artist / album-artist drift); drop the name-only and first-result fallbacks. If nothing
  matches, show "wird evtl. gerade gescannt" instead of opening a wrong album.

The download itself was correct all along (verified: it grabbed UPSAHL's official "I LIKE IT!"
visualizer) — only the notification's navigation was wrong. SW ns-v63.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Opus 4.8 committed 2026-08-01 02:30:53 +02:00
1 parent 1e206e8df3
commit 17bb527e1d
4 files changed
+23 -11

No files matched your search

+11 -6
View File
@@ -121,16 +121,21 @@ export async function _notifNavigate(notifId) {
try {
const r = await api('search3', `&query=${encodeURIComponent(albumQuery)}&artistCount=0&albumCount=10&songCount=0`);
const albums = r.searchResult3?.album || [];
const match = albums.find(a => norm(a.name) === norm(albumQuery) && norm(a.artist) === norm(n.navArtist))
|| albums.find(a => norm(a.name) === norm(albumQuery))
|| albums[0];
const na = norm(n.navArtist);
const nameEq = a => norm(a.name) === norm(albumQuery);
// Fuzzy artist compare (multi-artist / album-artist drift), but REQUIRE it when we know the
// artist: several artists share an album title ("I LIKE IT!"), and a name-only fallback used
// to open a completely different artist's album — the notification led to the wrong song.
const artistEq = a => { const aa = norm(a.artist); return !!na && (aa === na || aa.includes(na) || na.includes(aa)); };
const match = albums.find(a => nameEq(a) && artistEq(a))
|| (na ? null : albums.find(nameEq)); // name-only only when the artist is unknown
if (match) {
navigate('album-detail', { id: match.id, name: match.name, artist: match.artist || '', artistId: match.artistId || '', coverArt: match.coverArt || '' });
return;
}
} catch {}
}
toast('Album nicht gefunden — Library-Scan nötig?');
toast('Album noch nicht gefunden — evtl. wird die Library gerade gescannt');
return;
}
@@ -138,9 +143,9 @@ export async function _notifNavigate(notifId) {
try {
const r = await api('search3', `&query=${encodeURIComponent(n.navArtist)}&artistCount=5&albumCount=0&songCount=0`);
const artists = r.searchResult3?.artist || [];
const match = artists.find(a => norm(a.name) === norm(n.navArtist)) || artists[0];
const match = artists.find(a => norm(a.name) === norm(n.navArtist)); // no blind artists[0]
if (match) { navigate('artist-detail', { id: match.id, name: match.name }); return; }
} catch {}
toast('Künstler nicht gefunden — Library-Scan nötig?');
toast('Künstler noch nicht gefunden — evtl. wird die Library gerade gescannt');
}
}