Hide edit controls on activities the logged-in user does not own

This commit is contained in:
Davide Scaini
2026-05-03 18:51:52 +02:00
parent 48ffc5be8e
commit 680ef9d440
+9 -1
View File
@@ -14,7 +14,10 @@
export let athlete: AthleteZones | null = null;
const editUrl = import.meta.env.PUBLIC_EDIT_URL ?? '';
const editEnabled = editUrl !== '' || import.meta.env.PUBLIC_EDIT_ENABLED === 'true';
const editGloballyEnabled = editUrl !== '' || import.meta.env.PUBLIC_EDIT_ENABLED === 'true';
let currentHandle: string | null = null;
$: editEnabled = editGloballyEnabled && currentHandle !== null && currentHandle === activity.handle;
let detail: ActivityDetail | null = null;
let timeseries: Timeseries | null = null;
@@ -30,6 +33,11 @@
$: displayTitle = localTitle || activity.title;
onMount(async () => {
fetch('/api/me', { credentials: 'include' })
.then(r => r.ok ? r.json() : null)
.then(u => { if (u?.handle) currentHandle = u.handle; })
.catch(() => {});
try {
detail = await loadActivity(activity.id, activity.detail_url ?? '', base);
if (!detail) throw new Error('Activity not found');