From 2dd3d7c7e5f463f020c745a17a9c81a9f8bfb740 Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 23 May 2026 22:28:28 +0200 Subject: [PATCH] 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 --- src/ui.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ui.js b/src/ui.js index 9c44f97..4fefb00 100644 --- a/src/ui.js +++ b/src/ui.js @@ -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() {