fix low level issues

This commit is contained in:
Davide Scaini
2026-03-31 23:22:12 +02:00
parent 8f91503cf7
commit 81438231b4
19 changed files with 126 additions and 44 deletions
+11 -3
View File
@@ -9,6 +9,7 @@
let sport: Sport | 'all' = 'all';
let page = 0;
let loading = true;
let error = '';
let theme = 'dark';
let mounted = false;
@@ -28,9 +29,14 @@
sport = (params.get('sport') as Sport | 'all') ?? 'all';
page = parseInt(params.get('page') ?? '0', 10) || 0;
mounted = true;
const res = await fetch(`${import.meta.env.BASE_URL}data/index.json`);
const index: BASIndex = await res.json();
all = index.activities.filter(a => a.privacy !== 'private' && a.distance_m);
try {
const res = await fetch(`${import.meta.env.BASE_URL}data/index.json`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const index: BASIndex = await res.json();
all = index.activities.filter(a => a.privacy !== 'private' && a.distance_m);
} catch (e: any) {
error = e.message;
}
loading = false;
theme = document.documentElement.getAttribute('data-theme') ?? 'dark';
@@ -282,6 +288,8 @@
{#if loading}
<div class="h-64 rounded-xl bg-zinc-800 animate-pulse mb-6"></div>
{:else if error}
<p class="text-red-400 text-sm mt-4">{error}</p>
{:else}
<!-- Pagination controls -->