feat(#50): document & annotation comments #57

Merged
marcel merged 10 commits from feature/50-document-comments into main 2026-03-24 12:57:53 +01:00
2 changed files with 10 additions and 2 deletions
Showing only changes of commit 34c66f80fc - Show all commits

View File

@@ -120,6 +120,7 @@ const containerStyle = $derived(
data-annotation
role="button"
tabindex="0"
aria-label="Kommentare anzeigen"
onclick={() => onAnnotationClick?.(annotation.id)}
onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') onAnnotationClick?.(annotation.id); }}
onmouseenter={() => (hoveredId = annotation.id)}

View File

@@ -10,7 +10,7 @@ export async function load({ params, fetch }) {
const [docResult, commentsRes] = await Promise.all([
api.GET('/api/documents/{id}', { params: { path: { id } } }),
fetch(`${base}/api/documents/${id}/comments`)
fetch(`${base}/api/documents/${id}/comments`).catch(() => null)
]);
if (docResult.response.status === 401) throw redirect(302, '/login');
@@ -20,7 +20,14 @@ export async function load({ params, fetch }) {
throw error(docResult.response.status, getErrorMessage(code));
}
const comments = commentsRes.ok ? await commentsRes.json() : [];
let comments: unknown[] = [];
if (commentsRes?.ok) {
try {
comments = await commentsRes.json();
} catch {
// ignore invalid response
}
}
return { document: docResult.data!, comments };
}