fix: refresh edit form fields when getSong returns after edit mode opened
When the user opens the edit modal before the getSong async call returns, the form fields are populated from the initial song object (from the song list) which may omit albumArtist and other fields that only getSong returns. Now, when getSong resolves and edit mode is already visible, all form fields are updated to the authoritative Navidrome data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c69a8137c
commit
2dd3d7c7e5
1 file changed
+17
-1
@@ -272,7 +272,23 @@ export async function showSongInfo(s) {
|
||||
try {
|
||||
const r = await api('getSong', `&id=${s.id}`);
|
||||
const full = r.song;
|
||||
if (full) { S.infoSong = full; _renderInfoModal(full); }
|
||||
if (full) {
|
||||
S.infoSong = full;
|
||||
_renderInfoModal(full);
|
||||
// If edit mode was already opened before getSong returned, refresh the fields
|
||||
// so the form shows the authoritative data (albumArtist, etc.) from Navidrome
|
||||
if (document.getElementById('info-edit-mode').style.display !== 'none') {
|
||||
document.getElementById('ie-title').value = full.title || '';
|
||||
document.getElementById('ie-artist').value = full.artist || '';
|
||||
document.getElementById('ie-albumartist').value = full.albumArtist || '';
|
||||
document.getElementById('ie-album').value = full.album || '';
|
||||
document.getElementById('ie-genre').value = full.genre || '';
|
||||
document.getElementById('ie-year').value = full.year || '';
|
||||
document.getElementById('ie-track').value = full.track || '';
|
||||
document.getElementById('ie-disc').value = full.discNumber || '';
|
||||
document.getElementById('ie-totaltracks').value = full.albumSongCount || '';
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
export function closeInfoModal() {
|
||||
|
||||
Reference in new issue
Block a user