desktop: Disallow attachments when editing a draft comment

Drafts are kept in local storage and publish only their bodies, so a
file attached while editing one never reached the COB and peers saw a
broken link. The draft composer already disallowed attaching; editing
didn't.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-10 16:54:20 +01:00
parent 2ec2fecbdd
commit 0ef41cc23b
6 changed files with 48 additions and 1 deletions
@@ -5,6 +5,7 @@
import partial from "lodash/partial";
import { draftAttachmentsDisabled } from "@app/lib/codeComments";
import {
formatAnchor,
formatAnchorLines,
@@ -112,6 +113,9 @@
resolvedBy={comments.resolvedBy}
inline
draft={isDraftThread}
disableAttachments={isDraftThread
? draftAttachmentsDisabled
: undefined}
origin={comments.threadOrigins?.[thread.root.id]}
reactOnComment={isDraftThread ? undefined : comments.reactOnComment}
createReply={(comments.canReply ?? true)
+2 -1
View File
@@ -19,6 +19,7 @@
import type { CommentOwner } from "@app/lib/codeCommentActions";
import { commentActions } from "@app/lib/codeCommentActions";
import type { CodeComments } from "@app/lib/codeComments";
import { draftAttachmentsDisabled } from "@app/lib/codeComments";
import { resolutionsByComment } from "@app/lib/commentResolutions";
import { STANDALONE_COMMENTS } from "@app/lib/commentSources";
import { diffOptions } from "@app/lib/diffOptions.svelte";
@@ -525,7 +526,7 @@
// to it.)
canReply: !draftReview,
hideThreadFileHeader: true,
disableAttachments: "Publish your review to attach files",
disableAttachments: draftAttachmentsDisabled,
};
});
+5
View File
@@ -48,6 +48,8 @@
// activity timeline for the outer rail to connect to.
inline?: boolean;
draft?: boolean;
// See `ExtendedTextarea`.
disableAttachments?: boolean | string;
origin?: CommentOrigin;
// Rendered on the root comment's authorship line while it is hovered. The
// replies do not get it: it says something about the thread, not a comment.
@@ -73,6 +75,7 @@
canResolve = false,
inline = false,
draft = false,
disableAttachments,
origin,
hoverNote,
highlightedCommentId,
@@ -220,6 +223,7 @@
timestamp={reply.edits[0].timestamp}
body={reply.edits.slice(-1)[0].body}
embeds={embedMap(reply.embeds)}
{disableAttachments}
editComment={canModifyComment(reply.author.did) &&
editComment?.bind(null, reply.id)}
reactOnComment={reactOnComment?.bind(null, reply.id)}
@@ -274,6 +278,7 @@
timestamp={root.edits.slice(-1)[0].timestamp}
body={root.edits.slice(-1)[0].body}
embeds={embedMap(root.embeds)}
{disableAttachments}
editComment={canModifyComment(root.author.did) &&
editComment?.bind(null, root.id)}
reactOnComment={reactOnComment?.bind(null, root.id)}