diff --git a/webui/static/enrichment.js b/webui/static/enrichment.js index 2646f8e3..9428438c 100644 --- a/webui/static/enrichment.js +++ b/webui/static/enrichment.js @@ -1359,19 +1359,16 @@ function updateSimilarArtistsEnrichmentStatusFromData(data) { } async function toggleSimilarArtistsEnrichment() { + // Identical logic to the other orbs (e.g. toggleAmazonEnrichment): if the orb + // is 'active' (running) → pause, otherwise → resume. A paused orb isn't + // 'active', so this resumes it. try { - // Decide from the ACTUAL backend state, not the orb's CSS class — the - // class can be stale/absent (before the first status poll, or a 'complete' - // worker isn't 'active'/'paused'), which made class-based toggling pause a - // paused worker (no-op). Read paused, then do the opposite. - let paused = false; - try { - const s = await fetch('/api/enrichment/similar_artists/status'); - if (s.ok) paused = (await s.json()).paused === true; - } catch (_e) { /* fall back to pause */ } - const endpoint = paused ? '/api/enrichment/similar_artists/resume' : '/api/enrichment/similar_artists/pause'; + const button = document.getElementById('similar-artists-enrich-button'); + if (!button) return; + const isRunning = button.classList.contains('active'); + const endpoint = isRunning ? '/api/enrichment/similar_artists/pause' : '/api/enrichment/similar_artists/resume'; const response = await fetch(endpoint, { method: 'POST' }); - if (!response.ok) throw new Error(`Failed to ${paused ? 'resume' : 'pause'} Similar Artists enrichment`); + if (!response.ok) throw new Error(`Failed to ${isRunning ? 'pause' : 'resume'} Similar Artists enrichment`); await updateSimilarArtistsEnrichmentStatus(); } catch (error) { console.error('Error toggling Similar Artists enrichment:', error);