From 8a0622724352781002fd7e148793a201a0801dbb Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Fri, 15 May 2026 09:24:02 +0200 Subject: [PATCH] Feed date filter: early-stop global feed load, fix cross-date validation, show Loading while fetching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stop fetching combined-feed pages once the oldest activity in a batch predates the from-date (feed is newest-first, so everything needed is already loaded) - Show "Loading…" instead of "No activities found" while eager-load is in progress - Constrain From max to customTo (or today) and To min to customFrom so the range can't be inverted via the date pickers --- site/src/components/ActivityFeed.svelte | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/site/src/components/ActivityFeed.svelte b/site/src/components/ActivityFeed.svelte index 71659fb..0dac192 100644 --- a/site/src/components/ActivityFeed.svelte +++ b/site/src/components/ActivityFeed.svelte @@ -161,6 +161,8 @@ $: if ((query.trim() || customFrom || customTo || datePre !== 'all') && feedNextPage > 0 && !loadingAllFeedPages) { loadingAllFeedPages = true; (async () => { + // Snapshot at loop start — customFrom may change while we're fetching. + const fromFilter = customFrom; while (feedNextPage > 0) { const page = feedNextPage; feedNextPage = page < feedTotalPages ? page + 1 : 0; @@ -171,6 +173,12 @@ all = [...existing.values()].sort((a, b) => (b.started_at ?? '').localeCompare(a.started_at ?? ''), ); + // Feed is sorted newest-first. Once the oldest activity in this page + // predates our from-filter, everything needed is already loaded. + if (fromFilter && fresh.length > 0) { + const oldest = fresh.reduce((m, a) => (a.started_at ?? '') < (m.started_at ?? '') ? a : m); + if ((oldest.started_at ?? '') < fromFilter) { feedNextPage = 0; break; } + } } catch { /* ignore — partial results still useful */ } } loadingAllFeedPages = false; @@ -260,7 +268,7 @@ { datePre = 'all'; }} class="bg-transparent text-white text-sm focus:outline-none [color-scheme:dark]" /> @@ -270,6 +278,7 @@ { datePre = 'all'; }} class="bg-transparent text-white text-sm focus:outline-none [color-scheme:dark]" @@ -332,7 +341,7 @@

Could not load activities: {error}

{:else if withSearch.length === 0}

- {#if query.trim()}No activities match "{query.trim()}".{:else}No activities found.{/if} + {#if loadingAllFeedPages || loadingAllShards}Loading…{:else if query.trim()}No activities match "{query.trim()}".{:else}No activities found.{/if}

{:else}