Hide edit controls on activities the logged-in user does not own
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user