From 7b28e4202fae4b5222dc2c1884012ab710c5f61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Tue, 18 Mar 2025 18:15:36 -0600 Subject: [PATCH] Implement resolving and unresolving comments --- src/components/Diff.svelte | 65 ++++++++++++++++++++++++++++++---- src/components/FileDiff.svelte | 27 +++++++++++++- src/components/Review.svelte | 22 ++++++++++++ 3 files changed, 107 insertions(+), 7 deletions(-) diff --git a/src/components/Diff.svelte b/src/components/Diff.svelte index ac282bf7e..887927d50 100644 --- a/src/components/Diff.svelte +++ b/src/components/Diff.svelte @@ -1,6 +1,9 @@ @@ -192,6 +196,26 @@ }; } } + + let threadExpandedStates: Record = $state( + codeComments + ? Object.fromEntries( + codeComments.threads.map(t => [t.root.id, t.root.resolved]), + ) + : {}, + ); + + $effect(() => { + threadExpandedStates = codeComments + ? Object.fromEntries( + codeComments.threads.map(t => [t.root.id, t.root.resolved]), + ) + : {}; + }); + + function toggleCommentExpand(commentId: string) { + threadExpandedStates[commentId] = !threadExpandedStates[commentId]; + }