diff --git a/web_server.py b/web_server.py index 10877548..2e7b570c 100644 --- a/web_server.py +++ b/web_server.py @@ -32773,6 +32773,8 @@ def _push_playlist_to_server(batch_id, batch): playlist_id = batch.get('playlist_id', '') playlist_name = batch.get('playlist_name', '') if not playlist_name: + logger.info(f"[PlaylistPush] No playlist_name for batch {batch_id} - skipping server push") + database.update_sync_history_push_status(batch_id, 'skipped') return database.update_sync_history_push_status(batch_id, 'pushing') @@ -44211,10 +44213,7 @@ def get_discover_synced_playlists(): track_count = 0 else: # Personalized playlists come from the discovery pool - # familiar_favorites is not implemented — always report 0 - if ptype == 'familiar_favorites': - track_count = 0 - elif pool_count > 0: + if pool_count > 0: track_count = min(50, pool_count) else: track_count = 0 @@ -44310,10 +44309,13 @@ def manage_discover_auto_update(): settings[key] = bool(val) return jsonify({"success": True, "settings": settings}) - data = request.get_json() + data = request.get_json(silent=True) or {} playlist_type = data.get('playlist_type') enabled = data.get('enabled', False) + if not playlist_type: + return jsonify({"success": False, "error": "Missing playlist_type"}), 400 + is_lb_type = playlist_type and playlist_type.startswith('listenbrainz_') if playlist_type not in valid_types and not is_lb_type: return jsonify({"success": False, "error": f"Invalid playlist type: {playlist_type}"}), 400 diff --git a/webui/static/discover.js b/webui/static/discover.js index 78800af5..c0a9711b 100644 --- a/webui/static/discover.js +++ b/webui/static/discover.js @@ -9110,17 +9110,17 @@ function renderDiscoverSyncCard(playlist, container, sourceLabel) { const trackLabel = isEmpty ? 'No tracks yet' : `${playlist.track_count} tracks`; card.innerHTML = ` -
${playlist.icon}
+
${_esc(playlist.icon)}
-
${playlist.name} +
${_esc(playlist.name)} - ${sourceLabel || 'unknown'} + ${_esc(sourceLabel || 'unknown')} \u00b7 - ${trackLabel} + ${_esc(trackLabel)} \u00b7 - ${statusText} + ${_esc(statusText)} \u00b7 - ${lastSyncedText} + ${_esc(lastSyncedText)}
@@ -9128,26 +9128,43 @@ function renderDiscoverSyncCard(playlist, container, sourceLabel) {
-
`; + // Bind event listeners instead of inline handlers (avoids XSS from playlist names) + const autoUpdateToggle = card.querySelector('.discover-auto-update-toggle'); + if (autoUpdateToggle) { + autoUpdateToggle.addEventListener('change', function() { + toggleDiscoverAutoUpdate(playlist.type, this.checked); + }); + } + + const anyQualityToggle = card.querySelector('.discover-any-quality-toggle'); + if (anyQualityToggle) { + anyQualityToggle.id = `discover-any-quality-${playlist.type}`; + } + + const syncButton = card.querySelector('.discover-sync-btn'); + if (syncButton) { + syncButton.id = `discover-sync-btn-${playlist.type}`; + syncButton.addEventListener('click', () => syncDiscoverPlaylistFromTab(playlist.type, playlist.name)); + } + // Make the icon + info area clickable to view tracks if (!isEmpty) { const clickArea = card.querySelector('.discover-sync-card-info');