From a7c35340ec4c3493a42f3deb21ea7ede400c7045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Thu, 13 Aug 2026 15:24:54 +0200 Subject: [PATCH] Allow deleting discussion comments --- src/components/Comment.svelte | 12 +++++------- src/components/Discussion.svelte | 5 +++++ src/components/ReviewPage.svelte | 1 + src/components/Revision.svelte | 1 + src/views/repo/Issue.svelte | 22 ++++++++++++++++++++++ 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 47e386dd7..cc5270923 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -98,12 +98,6 @@ run: () => void | Promise; }; - const canDelete = $derived( - Boolean(deleteComment) && - currentUserNid !== undefined && - utils.publicKeyFromDid(author.did) === currentUserNid, - ); - const menuActions: MenuAction[] = $derived.by(() => { const actions: MenuAction[] = []; if (id) { @@ -117,7 +111,11 @@ if (editComment) { actions.push({ label: "Edit", icon: "edit", run: toggleEdit }); } - if (canDelete && deleteComment) { + // Gated by whoever passes it, exactly as `editComment` is — the protocol + // authorizes both the same way (a delegate, or the comment's own author), + // so a second, stricter rule here would only hide an action the node would + // have accepted. + if (deleteComment) { actions.push({ label: "Delete", icon: "trash", run: deleteComment }); } return actions; diff --git a/src/components/Discussion.svelte b/src/components/Discussion.svelte index 10407a665..d1fc64176 100644 --- a/src/components/Discussion.svelte +++ b/src/components/Discussion.svelte @@ -42,6 +42,9 @@ authors: Author[], reaction: string, ) => Promise; + // Optional: a discussion whose host has no way to redact a comment simply + // does not offer the action. + deleteComment?: (commentId: string) => Promise; rid: string; activityItems?: ActivityItem[]; renderActivity?: Snippet<[A, { hideAuthor: boolean }]>; @@ -58,6 +61,7 @@ createComment, editComment, reactOnComment, + deleteComment, rid, activityItems, renderActivity, @@ -272,6 +276,7 @@ repoDelegates.map(delegate => delegate.did), )} {editComment} + {deleteComment} createReply={createComment} {reactOnComment} />
diff --git a/src/components/ReviewPage.svelte b/src/components/ReviewPage.svelte index e634d2f7f..61cb88434 100644 --- a/src/components/ReviewPage.svelte +++ b/src/components/ReviewPage.svelte @@ -857,6 +857,7 @@ {config} createComment={createDiscussionComment} editComment={codeActions.editComment} + deleteComment={codeActions.deleteComment} reactOnComment={codeActions.reactOnComment} /> {/snippet} diff --git a/src/components/Revision.svelte b/src/components/Revision.svelte index 756714f9b..66ad14f78 100644 --- a/src/components/Revision.svelte +++ b/src/components/Revision.svelte @@ -1877,6 +1877,7 @@ {config} {createComment} editComment={codeActions.editComment} + deleteComment={codeActions.deleteComment} reactOnComment={codeActions.reactOnComment} {rid} {activityItems} diff --git a/src/views/repo/Issue.svelte b/src/views/repo/Issue.svelte index 6216cbacd..205218f7f 100644 --- a/src/views/repo/Issue.svelte +++ b/src/views/repo/Issue.svelte @@ -210,6 +210,27 @@ } } + /// The protocol authorizes a redaction for a delegate or the comment's own + /// author, and refuses it outright for an issue's root comment — which is the + /// issue body, and never appears in these threads. + async function deleteComment(id: string) { + try { + await invoke("edit_issue", { + rid: repo.rid, + cobId: issue.id, + action: { + type: "comment.redact", + id, + }, + opts: { announce: $nodeRunning && $announce }, + }); + } catch (error) { + console.error("Issue comment deletion failed: ", error); + } finally { + await reload(); + } + } + async function updateTitle(newTitle: string) { try { await invoke("edit_issue", { @@ -453,6 +474,7 @@ {config} {createComment} {editComment} + {deleteComment} {reactOnComment} rid={repo.rid} {activityItems}