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) {