diff --git a/frontend/src/lib/components/CampaignTrendChart.svelte b/frontend/src/lib/components/CampaignTrendChart.svelte index 7bc3c8d..0831cb6 100644 --- a/frontend/src/lib/components/CampaignTrendChart.svelte +++ b/frontend/src/lib/components/CampaignTrendChart.svelte @@ -23,23 +23,14 @@ // Debounced loading state to prevent flash let debouncedIsLoading = false; - let debouncedShowPending = false; let loadingTimeout; - let pendingTimeout; let hasAttemptedLoad = false; - const LOADING_DEBOUNCE_MS = 200; - const PENDING_DEBOUNCE_MS = 300; + const LOADING_DEBOUNCE_MS = 0; // show loading immediately $: { if (isLoading) { // Mark that we've attempted to load hasAttemptedLoad = true; - // Clear pending timeout since we're now loading - if (pendingTimeout) { - clearTimeout(pendingTimeout); - pendingTimeout = null; - } - debouncedShowPending = false; // Start showing loading after a delay if (!loadingTimeout) { loadingTimeout = setTimeout(() => { @@ -47,7 +38,7 @@ }, LOADING_DEBOUNCE_MS); } } else { - // Immediately hide loading and clear any pending timeout + // Immediately hide loading and clear timeout if (loadingTimeout) { clearTimeout(loadingTimeout); loadingTimeout = null; @@ -56,23 +47,6 @@ } } - // Show pending message only if we haven't attempted load and it's taking a while - $: { - if (!hasAttemptedLoad && !pendingTimeout) { - pendingTimeout = setTimeout(() => { - if (!hasAttemptedLoad) { - debouncedShowPending = true; - } - }, PENDING_DEBOUNCE_MS); - } else if (hasAttemptedLoad) { - if (pendingTimeout) { - clearTimeout(pendingTimeout); - pendingTimeout = null; - } - debouncedShowPending = false; - } - } - // localStorage keys for persisting chart settings const VISIBLE_METRICS_KEY = 'campaignTrend.visibleMetrics'; const TIME_RANGE_KEY = 'campaignTrend.selectedTimeRange'; @@ -1268,9 +1242,6 @@ if (loadingTimeout) { clearTimeout(loadingTimeout); } - if (pendingTimeout) { - clearTimeout(pendingTimeout); - } if (tooltipTimeout) { clearTimeout(tooltipTimeout); } @@ -1294,30 +1265,32 @@ class="chart-container w-full overflow-x-auto" style="height:0;overflow:hidden;visibility:hidden;position:absolute;" > - {#if !containerReady} -