Skip to content

Commit 9dcbae1

Browse files
KN4CK3Rzeripath
andcommitted
Keep attachments on tasklist update (go-gitea#16750)
* Send attachments too. * Use tasklist flag. * use action="ignoreAttachments" instead of "tasklist" * Use boolean parameter. Co-authored-by: zeripath <[email protected]>
1 parent 778a0bf commit 9dcbae1

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

routers/web/repo/issue.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,13 +2128,6 @@ func UpdateCommentContent(ctx *context.Context) {
21282128
return
21292129
}
21302130

2131-
if comment.Type == models.CommentTypeComment {
2132-
if err := comment.LoadAttachments(); err != nil {
2133-
ctx.ServerError("LoadAttachments", err)
2134-
return
2135-
}
2136-
}
2137-
21382131
if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
21392132
ctx.Error(http.StatusForbidden)
21402133
return
@@ -2156,8 +2149,18 @@ func UpdateCommentContent(ctx *context.Context) {
21562149
return
21572150
}
21582151

2159-
files := ctx.QueryStrings("files[]")
2160-
if err := updateAttachments(comment, files); err != nil {
2152+
if ctx.QueryBool("ignore_attachments") {
2153+
return
2154+
}
2155+
2156+
if comment.Type == models.CommentTypeComment {
2157+
if err := comment.LoadAttachments(); err != nil {
2158+
ctx.ServerError("LoadAttachments", err)
2159+
return
2160+
}
2161+
}
2162+
2163+
if err := updateAttachments(comment, ctx.QueryStrings("files[]")); err != nil {
21612164
ctx.ServerError("UpdateAttachments", err)
21622165
return
21632166
}

web_src/js/markup/tasklist.js

Lines changed: 2 additions & 1 deletion
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)