Move segment rescan button from segments list to athlete/segments tab
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
let segmentSummary: SegmentSummaryItem[] = [];
|
||||
let segmentsLoading = false;
|
||||
let segmentsHandle = '';
|
||||
let rescanning = false;
|
||||
let rescanMsg: string | null = null;
|
||||
|
||||
const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? '';
|
||||
const editEnabled = editUrl !== '' || import.meta.env.PUBLIC_EDIT_ENABLED === 'true';
|
||||
@@ -177,6 +179,29 @@
|
||||
|
||||
<!-- Segments tab -->
|
||||
{:else if activeTab === 'segments'}
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<span></span>
|
||||
<div class="flex items-center gap-3">
|
||||
{#if rescanMsg}<span class="text-xs text-zinc-400">{rescanMsg}</span>{/if}
|
||||
<button
|
||||
on:click={async () => {
|
||||
rescanning = true; rescanMsg = null;
|
||||
try {
|
||||
const r = await fetch('/api/me/segment-rescan', { method: 'POST', credentials: 'include' });
|
||||
const d = await r.json();
|
||||
if (r.ok) {
|
||||
rescanMsg = `Found ${d.efforts_found} effort${d.efforts_found !== 1 ? 's' : ''}.`;
|
||||
// Refresh the summary
|
||||
segmentSummary = [];
|
||||
} else rescanMsg = d.detail ?? 'Rescan failed.';
|
||||
} catch { rescanMsg = 'Could not reach server.'; }
|
||||
rescanning = false;
|
||||
}}
|
||||
disabled={rescanning}
|
||||
class="text-xs px-3 py-1.5 rounded-lg border border-zinc-700 text-zinc-400 hover:border-zinc-500 hover:text-white transition-colors disabled:opacity-40"
|
||||
>{rescanning ? 'Scanning…' : 'Rescan all activities'}</button>
|
||||
</div>
|
||||
</div>
|
||||
{#if segmentsLoading}
|
||||
<p class="text-zinc-500 text-sm">Loading segments…</p>
|
||||
{:else if segmentSummary.length === 0}
|
||||
|
||||
Reference in New Issue
Block a user