Moar federation
This commit is contained in:
parent
45e9030c1d
commit
a3ff96653a
1 changed files with 21 additions and 5 deletions
|
|
@ -317,11 +317,8 @@
|
|||
|
||||
// Show Edit/Delete buttons only if user is logged in and owns the activity
|
||||
if (FitPubAuth.isAuthenticated()) {
|
||||
const currentUser = FitPubAuth.getCurrentUser();
|
||||
if (currentUser && currentUser.id === activity.userId) {
|
||||
document.getElementById('activityActions').style.display = 'block';
|
||||
document.getElementById('editBtn').href = `/activities/${activity.id}/edit`;
|
||||
}
|
||||
// Fetch current user to check if they own this activity
|
||||
checkActivityOwnership(activity);
|
||||
}
|
||||
|
||||
// Metrics
|
||||
|
|
@ -358,6 +355,25 @@
|
|||
setupSocialInteractions(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user owns this activity and show edit/delete buttons if so.
|
||||
*/
|
||||
async function checkActivityOwnership(activity) {
|
||||
try {
|
||||
const response = await FitPubAuth.authenticatedFetch('/api/users/me');
|
||||
if (response.ok) {
|
||||
const currentUser = await response.json();
|
||||
if (currentUser.id === activity.userId) {
|
||||
document.getElementById('activityActions').style.display = 'block';
|
||||
document.getElementById('editBtn').href = `/activities/${activity.id}/edit`;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking activity ownership:', error);
|
||||
// Don't show buttons if there's an error
|
||||
}
|
||||
}
|
||||
|
||||
function renderMap(simplifiedTrack) {
|
||||
// Parse GeoJSON from simplifiedTrack
|
||||
const geoJson = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue