]> source.dussan.org Git - gitea.git/commitdiff
Keep attachments on tasklist update (#16750)
authorKN4CK3R <admin@oldschoolhack.me>
Fri, 20 Aug 2021 19:26:19 +0000 (21:26 +0200)
committerGitHub <noreply@github.com>
Fri, 20 Aug 2021 19:26:19 +0000 (15:26 -0400)
* Send attachments too.

* Use tasklist flag.

* use action="ignoreAttachments" instead of "tasklist"

* Use boolean parameter.

Co-authored-by: zeripath <art27@cantab.net>
routers/web/repo/issue.go
web_src/js/markup/tasklist.js

index ff83be441026a9e18668fe142ec82cc7c2e6cb5b..56561c6168d61845f4531300f597daab2e6f8920 100644 (file)
@@ -2127,13 +2127,6 @@ func UpdateCommentContent(ctx *context.Context) {
                return
        }
 
-       if comment.Type == models.CommentTypeComment {
-               if err := comment.LoadAttachments(); err != nil {
-                       ctx.ServerError("LoadAttachments", err)
-                       return
-               }
-       }
-
        if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
                ctx.Error(http.StatusForbidden)
                return
@@ -2155,6 +2148,17 @@ func UpdateCommentContent(ctx *context.Context) {
                return
        }
 
+       if ctx.FormBool("ignore_attachments") {
+               return
+       }
+
+       if comment.Type == models.CommentTypeComment {
+               if err := comment.LoadAttachments(); err != nil {
+                       ctx.ServerError("LoadAttachments", err)
+                       return
+               }
+       }
+
        if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil {
                ctx.ServerError("UpdateAttachments", err)
                return
index 24b29ddb7afc3052df77d8406522b17f453a603b..ea1a1f824a13ef177852dee2a9478de90f1c610b 100644 (file)
@@ -46,9 +46,10 @@ export function initMarkupTasklist() {
           const {updateUrl, context} = editContentZone.dataset;
 
           await $.post(updateUrl, {
+            ignore_attachments: true,
             _csrf: window.config.csrf,
             content: newContent,
-            context,
+            context
           });
 
           rawContent.textContent = newContent;