fix(transcription): always show comment list, compose box on demand
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Has been cancelled
CI / Backend Unit Tests (pull_request) Has been cancelled
CI / E2E Tests (pull_request) Has been cancelled

Comments were only visible after clicking "Kommentieren". Now:
- Comment list always renders (CommentThread with loadOnMount=true)
- Compose box hidden by default (showCompose prop on CommentThread)
- Clicking "Kommentieren" sets commentOpen=true → shows compose box
- Closing hides compose box but comments remain visible

This separates "viewing comments" (always) from "writing a comment"
(on demand via Kommentieren button).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-05 22:02:15 +02:00
parent 6475ebcc60
commit be4f1ed73b
4 changed files with 17 additions and 60 deletions

View File

@@ -30,34 +30,9 @@ let activeBlockId: string | null = $state(null);
let saveStates = new SvelteMap<string, SaveState>();
let debounceTimers = new SvelteMap<string, ReturnType<typeof setTimeout>>();
let pendingTexts = new SvelteMap<string, string>();
let commentCounts = new SvelteMap<string, number>();
let sortedBlocks = $derived([...blocks].sort((a, b) => a.sortOrder - b.sortOrder));
let hasBlocks = $derived(blocks.length > 0);
async function loadCommentCounts() {
for (const block of blocks) {
try {
const res = await fetch(
`/api/documents/${documentId}/transcription-blocks/${block.id}/comments`
);
if (res.ok) {
const comments = (await res.json()) as Array<{ replies: unknown[] }>;
const total = comments.reduce((s, c) => s + 1 + (c.replies?.length ?? 0), 0);
commentCounts.set(block.id, total);
}
} catch {
// ignore
}
}
}
$effect(() => {
if (blocks.length > 0) {
loadCommentCounts();
}
});
function getSaveState(blockId: string): SaveState {
return saveStates.get(blockId) ?? 'idle';
}
@@ -191,7 +166,6 @@ $effect(() => {
saveState={getSaveState(block.id)}
canComment={canComment}
currentUserId={currentUserId}
commentCount={commentCounts.get(block.id) ?? 0}
onTextChange={(text) => handleTextChange(block.id, text)}
onFocus={() => handleFocus(block.id)}
onDeleteClick={() => handleDelete(block.id)}