feat(#50): document & annotation comments #57
@@ -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)}
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user