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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user