From bd64f437cda9face32827656ad5065ea1d871fe2 Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Tue, 3 Feb 2026 16:54:40 -0500 Subject: [PATCH] Fix web UI infinite loop and improve cookie age tracking - Add cookieDateInitialized flag to prevent infinite init-cookie-date calls - Auto-initialize cookie date when cookie exists but date not tracked - Improve local vs external track detection in Jellyfin playlists - Support multiple Spotify playlist ID formats (ID, URI, URL) - Fix pragma warnings in legacy playlist parsing code - Simplify GetPlaylistTrackStats to check Path property for local tracks --- allstarr/Program.cs | 10 +++++----- allstarr/wwwroot/index.html | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/allstarr/Program.cs b/allstarr/Program.cs index 8cce911..dc5e033 100644 --- a/allstarr/Program.cs +++ b/allstarr/Program.cs @@ -194,7 +194,7 @@ builder.Services.Configure(options => { Console.WriteLine("Parsing legacy Spotify playlist format..."); - #pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618 // Type or member is obsolete // Clear any auto-bound values from the Bind() call above // The auto-binder doesn't handle comma-separated strings correctly @@ -262,7 +262,7 @@ builder.Services.Configure(options => }); Console.WriteLine($" [{i}] {name} (ID: {options.PlaylistIds[i]}, Position: {position})"); } - #pragma warning restore CS0618 +#pragma warning restore CS0618 } else if (hasLegacyConfig && options.Playlists.Count > 0) { @@ -270,14 +270,14 @@ builder.Services.Configure(options => // Clear it and re-parse properly Console.WriteLine($"DEBUG: Bind() incorrectly populated {options.Playlists.Count} playlists, clearing and re-parsing..."); options.Playlists.Clear(); + +#pragma warning disable CS0618 // Type or member is obsolete options.PlaylistIds.Clear(); options.PlaylistNames.Clear(); options.PlaylistLocalTracksPositions.Clear(); Console.WriteLine("Parsing legacy Spotify playlist format..."); - #pragma warning disable CS0618 // Type or member is obsolete - if (!string.IsNullOrWhiteSpace(playlistIdsEnv)) { options.PlaylistIds = playlistIdsEnv @@ -338,7 +338,7 @@ builder.Services.Configure(options => }); Console.WriteLine($" [{i}] {name} (ID: {options.PlaylistIds[i]}, Position: {position})"); } - #pragma warning restore CS0618 +#pragma warning restore CS0618 } else { diff --git a/allstarr/wwwroot/index.html b/allstarr/wwwroot/index.html index fb51fec..d1632ba 100644 --- a/allstarr/wwwroot/index.html +++ b/allstarr/wwwroot/index.html @@ -848,6 +848,9 @@ let currentEditType = null; let currentEditOptions = null; + // Track if we've already initialized the cookie date to prevent infinite loop + let cookieDateInitialized = false; + // Tab switching document.querySelectorAll('.tab').forEach(tab => { tab.addEventListener('click', () => { @@ -921,21 +924,25 @@ // Initialize cookie date if cookie exists but date is not set async function initCookieDate() { + if (cookieDateInitialized) { + console.log('Cookie date already initialized, skipping'); + return; + } + + cookieDateInitialized = true; + try { const res = await fetch('/api/admin/config/init-cookie-date', { method: 'POST' }); if (res.ok) { - console.log('Cookie date initialized successfully'); - // Refresh status after initialization - setTimeout(() => { - fetchStatus(); - fetchConfig(); - }, 500); + console.log('Cookie date initialized successfully - restart container to apply'); + showToast('Cookie date set. Restart container to apply changes.', 'success'); } else { const data = await res.json(); console.log('Cookie date init response:', data); } } catch (error) { console.error('Failed to init cookie date:', error); + cookieDateInitialized = false; // Allow retry on error } }