pregenerated segments, tolerant matching, profile segment list, segment map

This commit is contained in:
Vincent van der Wal
2026-07-22 17:11:38 +02:00
parent da9f7c6e1a
commit 2c82445291
7 changed files with 445 additions and 17 deletions
+14 -4
View File
@@ -1,6 +1,6 @@
import { error } from '@sveltejs/kit';
import { getSegment, segmentLeaderboard } from '$lib/server/db';
import type { PageServerLoad } from './$types';
import { error, redirect } from '@sveltejs/kit';
import { deleteSegment, getSegment, segmentLeaderboard } from '$lib/server/db';
import type { Actions, PageServerLoad } from './$types';
import type { TrackPt } from '$lib/server/segments';
export const load: PageServerLoad = ({ params, locals }) => {
@@ -12,6 +12,16 @@ export const load: PageServerLoad = ({ params, locals }) => {
segment: { ...segment, points: undefined },
latlngs: points.map((p) => [p.lat, p.lon] as [number, number]),
leaderboard: segmentLeaderboard(segment.id),
myUserId: locals.user?.id ?? null
myUserId: locals.user?.id ?? null,
canDelete:
!!locals.user && (segment.creator_id === locals.user.id || segment.creator_id === null)
};
};
export const actions: Actions = {
delete: async ({ params, locals }) => {
if (!locals.user) error(401, 'Not signed in');
deleteSegment(Number(params.id), locals.user.id);
redirect(303, '/segments');
}
};