Skip to content

Commit dc26136

Browse files
KN4CK3Rzeripath
andauthored
Keep attachments on tasklist update (#16750)
* Send attachments too. * Use tasklist flag. * use action="ignoreAttachments" instead of "tasklist" * Use boolean parameter. Co-authored-by: zeripath <[email protected]>
1 parent 3b2ed47 commit dc26136

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

routers/web/repo/issue.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -2127,13 +2127,6 @@ func UpdateCommentContent(ctx *context.Context) {
21272127
return
21282128
}
21292129

2130-
if comment.Type == models.CommentTypeComment {
2131-
if err := comment.LoadAttachments(); err != nil {
2132-
ctx.ServerError("LoadAttachments", err)
2133-
return
2134-
}
2135-
}
2136-
21372130
if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
21382131
ctx.Error(http.StatusForbidden)
21392132
return
@@ -2155,6 +2148,17 @@ func UpdateCommentContent(ctx *context.Context) {
21552148
return
21562149
}
21572150

2151+
if ctx.FormBool("ignore_attachments") {
2152+
return
2153+
}
2154+
2155+
if comment.Type == models.CommentTypeComment {
2156+
if err := comment.LoadAttachments(); err != nil {
2157+
ctx.ServerError("LoadAttachments", err)
2158+
return
2159+
}
2160+
}
2161+
21582162
if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil {
21592163
ctx.ServerError("UpdateAttachments", err)
21602164
return

web_src/js/markup/tasklist.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ export function initMarkupTasklist() {
4646
const {updateUrl, context} = editContentZone.dataset;
4747

4848
await $.post(updateUrl, {
49+
ignore_attachments: true,
4950
_csrf: window.config.csrf,
5051
content: newContent,
51-
context,
52+
context
5253
});
5354

5455
rawContent.textContent = newContent;

0 commit comments

Comments
 (0)