From 5e866463eaa508d29a39871c93d8d86a52b283ab Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Tue, 9 Dec 2025 11:36:59 -0800 Subject: [PATCH] Prevent duplicate playlist syncs and update UI Added checks to prevent starting multiple syncs for the same playlist and updated the sync button state immediately for better user feedback. The sync button is now disabled and shows a loading state while syncing is in progress. --- webui/static/script.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/webui/static/script.js b/webui/static/script.js index 659b8702..9d1981cb 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -3942,7 +3942,10 @@ function showPlaylistDetailsModal(playlist) { // Check if there's a completed download missing tracks process for this playlist const activeProcess = activeDownloadProcesses[playlist.id]; const hasCompletedProcess = activeProcess && activeProcess.status === 'complete'; - + + // Check if sync is currently running for this playlist + const isSyncing = !!activeSyncPollers[playlist.id]; + modal.innerHTML = ` `; @@ -7011,6 +7014,19 @@ async function startPlaylistSync(playlistId) { } console.log(`✅ Found playlist: ${playlist.name} with ${playlist.track_count || 'unknown'} tracks`); + // Check if already syncing to prevent duplicate syncs + if (activeSyncPollers[playlistId]) { + showToast('Sync already in progress for this playlist', 'warning'); + return; + } + + // Update button state immediately for user feedback + const syncBtn = document.getElementById(`sync-btn-${playlistId}`); + if (syncBtn) { + syncBtn.disabled = true; + syncBtn.textContent = '⏳ Syncing...'; + } + // Ensure we have the full track list before starting let tracks = playlistTrackCache[playlistId]; if (!tracks) {