feat: show pace (min/km) for running, hiking, walking, other activities

Cycling keeps km/h; pace sports show e.g. "5:30 /km" in the feed card,
activity stat panel (avg/max), and laps table.
This commit is contained in:
Davide Scaini
2026-06-02 16:23:03 +02:00
parent 1dca00d5e3
commit 13859a34d3
3 changed files with 20 additions and 6 deletions
+14
View File
@@ -1,5 +1,19 @@
import type { Privacy, Sport } from './types';
const PACE_SPORTS: Set<Sport> = new Set(['running', 'hiking', 'walking', 'other']);
export function isPaceSport(sport: Sport): boolean {
return PACE_SPORTS.has(sport);
}
export function formatPace(kmh: number | null): string {
if (kmh == null || kmh <= 0) return '—';
const secsPerKm = 3600 / kmh;
const m = Math.floor(secsPerKm / 60);
const s = Math.round(secsPerKm % 60);
return `${m}:${s.toString().padStart(2, '0')} /km`;
}
/** True for "unlisted" activities (and the legacy "private" alias).
* Use this everywhere instead of comparing against 'private' directly. */
export function isUnlisted(privacy: Privacy | string | null | undefined): boolean {