Move segment rescan button from segments list to athlete/segments tab
This commit is contained in:
@@ -23,8 +23,6 @@
|
||||
let loading = false;
|
||||
let selectedId: string | null = null;
|
||||
let fetchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let rescanning = false;
|
||||
let rescanMsg: string | null = null;
|
||||
|
||||
const TILE_STYLE = 'https://tiles.openfreemap.org/styles/positron';
|
||||
const SEG_COLOR = '#f59e0b';
|
||||
@@ -125,20 +123,6 @@
|
||||
['case', ['==', ['get', 'id'], selectedId ?? ''], 5, 3]);
|
||||
}
|
||||
|
||||
async function rescanAll() {
|
||||
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' : ''}.`;
|
||||
else rescanMsg = d.detail ?? 'Rescan failed.';
|
||||
} catch {
|
||||
rescanMsg = 'Could not reach server.';
|
||||
}
|
||||
rescanning = false;
|
||||
}
|
||||
|
||||
async function deleteSegment(id: string) {
|
||||
if (!confirm('Delete this segment? This cannot be undone.')) return;
|
||||
try {
|
||||
@@ -160,21 +144,10 @@
|
||||
<div class="flex items-center justify-between px-4 py-3 border-b shrink-0"
|
||||
style="border-color: var(--border)">
|
||||
<h1 class="text-lg font-bold text-white">Segments</h1>
|
||||
<div class="flex items-center gap-2">
|
||||
{#if rescanMsg}
|
||||
<span class="text-xs text-zinc-400">{rescanMsg}</span>
|
||||
{/if}
|
||||
<button
|
||||
on:click={rescanAll}
|
||||
disabled={rescanning}
|
||||
title="Rescan all your activities against all segments"
|
||||
class="px-3 py-1.5 rounded-lg text-sm border border-zinc-700 text-zinc-400 hover:border-zinc-500 hover:text-white transition-colors disabled:opacity-40"
|
||||
>{rescanning ? 'Scanning…' : 'Rescan all'}</button>
|
||||
<a href="{base}segments/new/"
|
||||
class="px-3 py-1.5 rounded-lg text-sm bg-blue-600 hover:bg-blue-500 text-white transition-colors">
|
||||
+ New segment
|
||||
</a>
|
||||
</div>
|
||||
<a href="{base}segments/new/"
|
||||
class="px-3 py-1.5 rounded-lg text-sm bg-blue-600 hover:bg-blue-500 text-white transition-colors">
|
||||
+ New segment
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Map -->
|
||||
|
||||
Reference in New Issue
Block a user