fix low level issues
This commit is contained in:
@@ -120,7 +120,17 @@
|
||||
return el;
|
||||
}
|
||||
|
||||
onDestroy(() => map?.remove());
|
||||
onDestroy(() => {
|
||||
resizeObserver?.disconnect();
|
||||
map?.remove();
|
||||
});
|
||||
|
||||
let resizeObserver: ResizeObserver;
|
||||
$: if (mapEl && map) {
|
||||
resizeObserver?.disconnect();
|
||||
resizeObserver = new ResizeObserver(() => map?.resize());
|
||||
resizeObserver.observe(mapEl);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div bind:this={mapEl} class="w-full h-full"></div>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import RecordsView from './RecordsView.svelte';
|
||||
import AthleteDrawer from './AthleteDrawer.svelte';
|
||||
|
||||
export let base: string = '/';
|
||||
|
||||
let athlete: AthleteJson | null = null;
|
||||
let activities: ActivitySummary[] = [];
|
||||
let loading = true;
|
||||
@@ -106,7 +108,7 @@
|
||||
|
||||
<!-- Records tab -->
|
||||
{:else if activeTab === 'records'}
|
||||
<RecordsView {athlete} />
|
||||
<RecordsView {athlete} {base} />
|
||||
|
||||
<!-- Profile tab -->
|
||||
{:else if activeTab === 'profile'}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { formatDate, sportIcon, sportColor } from '../lib/format';
|
||||
|
||||
export let athlete: AthleteJson;
|
||||
export let base: string = '/';
|
||||
|
||||
// ── Distance label formatting ──────────────────────────────────────────────
|
||||
function distLabel(km: number): string {
|
||||
@@ -96,7 +97,7 @@
|
||||
return (athlete as any).records?.[sport]?.[key] ?? null;
|
||||
}
|
||||
|
||||
const activityUrl = (id: string) => `/activity/${id}/`;
|
||||
const activityUrl = (id: string) => `${base}activity/${id}/`;
|
||||
</script>
|
||||
|
||||
<!-- Sport tabs -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
@@ -5,6 +5,7 @@ interface Props {
|
||||
}
|
||||
const { title = 'BincioActivity', description = 'Your personal activity stats' } = Astro.props;
|
||||
const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? '';
|
||||
const baseUrl = import.meta.env.BASE_URL ?? '/';
|
||||
---
|
||||
<!doctype html>
|
||||
<html lang="en" data-theme="dark">
|
||||
@@ -174,7 +175,7 @@ const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? '';
|
||||
</script>
|
||||
|
||||
{editUrl && (
|
||||
<script define:vars={{ editUrl }}>
|
||||
<script define:vars={{ editUrl, baseUrl }}>
|
||||
const modal = document.getElementById('upload-modal');
|
||||
const drop = document.getElementById('upload-drop');
|
||||
const input = document.getElementById('upload-input');
|
||||
@@ -217,7 +218,7 @@ const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? '';
|
||||
const d = await r.json();
|
||||
status.textContent = 'Done! Opening activity…';
|
||||
status.style.color = '#4ade80';
|
||||
setTimeout(() => { window.location.href = `/activity/${d.id}/`; }, 600);
|
||||
setTimeout(() => { window.location.href = `${baseUrl}activity/${d.id}/`; }, 600);
|
||||
} catch (e) {
|
||||
status.textContent = 'Error: ' + e.message;
|
||||
status.style.color = '#f87171';
|
||||
|
||||
@@ -12,6 +12,7 @@ export function formatDistance(m: number | null, unit: 'metric' | 'imperial' = '
|
||||
|
||||
export function formatDuration(s: number | null): string {
|
||||
if (s == null) return '—';
|
||||
s = Math.floor(s);
|
||||
const h = Math.floor(s / 3600);
|
||||
const m = Math.floor((s % 3600) / 60);
|
||||
const sec = s % 60;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
import Base from '../../layouts/Base.astro';
|
||||
import AthleteView from '../../components/AthleteView.svelte';
|
||||
const base = import.meta.env.BASE_URL;
|
||||
---
|
||||
<Base title="Athlete — BincioActivity">
|
||||
<h1 class="text-2xl font-bold text-white mb-6">Athlete</h1>
|
||||
<AthleteView client:load />
|
||||
<AthleteView {base} client:load />
|
||||
</Base>
|
||||
|
||||
Reference in New Issue
Block a user