diff --git a/site/src/components/ActivityFeed.svelte b/site/src/components/ActivityFeed.svelte index 05e4b6c..0282a3a 100644 --- a/site/src/components/ActivityFeed.svelte +++ b/site/src/components/ActivityFeed.svelte @@ -42,6 +42,8 @@ let datePre = 'all'; let dateFrom = ''; let dateTo = ''; + let customFrom = ''; + let customTo = ''; let query = ''; let shown = PAGE_SIZE; let loading = true; @@ -83,7 +85,8 @@ return true; }); $: allYears = [...new Set(all.map(a => a.started_at?.slice(0, 4)).filter(Boolean) as string[])].sort().reverse(); - $: ({ dateFrom, dateTo } = computeDateRange(datePre)); + $: dateFrom = (customFrom || customTo) ? customFrom : computeDateRange(datePre).dateFrom; + $: dateTo = (customFrom || customTo) ? (customTo ? customTo + '￿' : '') : computeDateRange(datePre).dateTo; $: withDate = !dateFrom && !dateTo ? withPrivacy : withPrivacy.filter(a => (!dateFrom || a.started_at >= dateFrom) && (!dateTo || a.started_at < dateTo) ); @@ -126,7 +129,7 @@ } } - $: if (sport || datePre || query) shown = PAGE_SIZE; // reset pagination on filter change + $: if (sport || datePre || query || customFrom || customTo) shown = PAGE_SIZE; // reset pagination on filter change // When a search query is active, eagerly load all remaining shards so the // full history is searched (not just the initially-loaded recent year). @@ -153,18 +156,22 @@ $: if (mounted) { const params = new URLSearchParams(window.location.search); if (sport === 'all') params.delete('sport'); else params.set('sport', sport); - if (datePre === 'all') params.delete('date'); else params.set('date', datePre); + if (datePre === 'all' || customFrom || customTo) params.delete('date'); else params.set('date', datePre); if (!query.trim()) params.delete('q'); else params.set('q', query.trim()); + if (!customFrom) params.delete('from'); else params.set('from', customFrom); + if (!customTo) params.delete('to'); else params.set('to', customTo); const qs = params.toString(); history.replaceState(null, '', qs ? `?${qs}` : window.location.pathname); } onMount(async () => { const params = new URLSearchParams(window.location.search); - sport = (params.get('sport') as Sport | 'all') ?? 'all'; - datePre = params.get('date') ?? 'all'; - query = params.get('q') ?? ''; - mounted = true; + sport = (params.get('sport') as Sport | 'all') ?? 'all'; + datePre = params.get('date') ?? 'all'; + query = params.get('q') ?? ''; + customFrom = params.get('from') ?? ''; + customTo = params.get('to') ?? ''; + mounted = true; // Resolve the logged-in handle so we can show the owner their private activities. if ((window as any).__bincioMe !== undefined) { @@ -215,14 +222,34 @@ ]; - -
+ +
+
+
+ From + { datePre = 'all'; }} + class="bg-transparent text-white text-sm focus:outline-none [color-scheme:dark]" + /> +
+
+ To + { datePre = 'all'; }} + class="bg-transparent text-white text-sm focus:outline-none [color-scheme:dark]" + /> +
+
@@ -254,14 +281,15 @@
{#each [{ value: 'all', label: 'All time' }, { value: '7d', label: '7 days' }, { value: '30d', label: '30 days' }, { value: '6mo', label: '6 months' }, ...allYears.map(y => ({ value: y, label: y }))] as d} + {@const isActive = datePre === d.value && !customFrom && !customTo}