unify single user and multi user behaviour
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
import { loadIndex, loadAthlete } from '../lib/dataloader';
|
||||
|
||||
export let base: string = '/';
|
||||
/** Explicit index URL for multi-user per-user pages (user's shard). */
|
||||
export let indexUrl: string = '';
|
||||
/** Explicit athlete.json URL for multi-user per-user pages. */
|
||||
export let athleteUrl: string = '';
|
||||
|
||||
let athlete: AthleteJson | null = null;
|
||||
let activities: ActivitySummary[] = [];
|
||||
@@ -34,8 +38,8 @@
|
||||
mounted = true;
|
||||
try {
|
||||
const [athleteData, index] = await Promise.all([
|
||||
loadAthlete(import.meta.env.BASE_URL),
|
||||
loadIndex(import.meta.env.BASE_URL),
|
||||
loadAthlete(import.meta.env.BASE_URL, athleteUrl || undefined),
|
||||
loadIndex(import.meta.env.BASE_URL, indexUrl || undefined),
|
||||
]);
|
||||
if (!athleteData) throw new Error('athlete.json not found — run bincio extract first');
|
||||
athlete = athleteData;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
import { formatDistance, formatDuration, sportIcon, sportColor, sportLabel } from '../lib/format';
|
||||
import { loadIndex } from '../lib/dataloader';
|
||||
|
||||
/** Explicit index URL — use for per-user stats pages in multi-user mode. */
|
||||
export let indexUrl: string = '';
|
||||
|
||||
const PAGE_YEARS = 4;
|
||||
|
||||
let all: ActivitySummary[] = [];
|
||||
@@ -31,7 +34,7 @@
|
||||
page = parseInt(params.get('page') ?? '0', 10) || 0;
|
||||
mounted = true;
|
||||
try {
|
||||
const index = await loadIndex(import.meta.env.BASE_URL);
|
||||
const index = await loadIndex(import.meta.env.BASE_URL, indexUrl || undefined);
|
||||
all = index.activities.filter(a => a.privacy !== 'private' && a.distance_m);
|
||||
} catch (e: any) {
|
||||
error = e.message;
|
||||
|
||||
Reference in New Issue
Block a user