feat: show accumulated distance per gear item in gear tab
Compute total distance from allActivities where gear name matches and display it inline next to each gear item. Also add gear field to ActivitySummary type so index shard gear data is accessible in the UI.
This commit is contained in:
@@ -151,6 +151,13 @@
|
||||
|
||||
$: if (activeTab === 'gear' && isOwner && !gearFetched && !gearLoading) gearFetch();
|
||||
|
||||
$: gearDistances = Object.fromEntries(
|
||||
gearItems.map(g => [
|
||||
g.name,
|
||||
allActivities.filter(a => a.gear === g.name).reduce((sum, a) => sum + (a.distance_m ?? 0), 0),
|
||||
])
|
||||
);
|
||||
|
||||
$: if (activeTab === 'segments' && segmentsHandle && !segmentsFetched && !segmentsLoading) {
|
||||
segmentsLoading = true;
|
||||
segmentsFetched = true;
|
||||
@@ -483,6 +490,9 @@
|
||||
<div class="px-4 py-3 border-b border-zinc-800 flex items-center gap-3 last:border-0">
|
||||
<span class="text-lg leading-none">{GEAR_ICONS[item.type] ?? '⚙️'}</span>
|
||||
<span class="flex-1 text-sm text-white" class:text-zinc-500={item.retired}>{item.name}</span>
|
||||
{#if gearDistances[item.name] > 0}
|
||||
<span class="text-xs text-zinc-400">{formatDistance(gearDistances[item.name])}</span>
|
||||
{/if}
|
||||
{#if item.retired}
|
||||
<span class="text-xs text-zinc-600 border border-zinc-700 rounded px-1.5 py-0.5">Retired</span>
|
||||
{/if}
|
||||
|
||||
@@ -69,6 +69,7 @@ export interface ActivitySummary {
|
||||
climbing_vam_mh?: number | null;
|
||||
climbing_time_s?: number | null;
|
||||
source: string | null;
|
||||
gear: string | null;
|
||||
privacy: Privacy;
|
||||
detail_url: string | null;
|
||||
track_url: string | null;
|
||||
|
||||
Reference in New Issue
Block a user