From 33391e04feb6be1c2f8bec0928f500df0f110d89 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 4 Aug 2020 22:30:02 +0100 Subject: [PATCH] Prevent empty div when editing comment (#12404) * Prevent empty div when editing comment The template for attachments needs to remove whitespace and return empty when there are no attachments. Fix #10220 --- routers/repo/issue.go | 6 +++--- templates/repo/issue/view_content/attachments.tmpl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index b3af6705c..1f8f48413 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1975,7 +1975,7 @@ func updateAttachments(item interface{}, files []string) error { case *models.Comment: attachments = content.Attachments default: - return fmt.Errorf("Unknow Type") + return fmt.Errorf("Unknown Type: %T", content) } for i := 0; i < len(attachments); i++ { if util.IsStringInSlice(attachments[i].UUID, files) { @@ -1993,7 +1993,7 @@ func updateAttachments(item interface{}, files []string) error { case *models.Comment: err = content.UpdateAttachments(files) default: - return fmt.Errorf("Unknow Type") + return fmt.Errorf("Unknown Type: %T", content) } if err != nil { return err @@ -2005,7 +2005,7 @@ func updateAttachments(item interface{}, files []string) error { case *models.Comment: content.Attachments, err = models.GetAttachmentsByCommentID(content.ID) default: - return fmt.Errorf("Unknow Type") + return fmt.Errorf("Unknown Type: %T", content) } return err } diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index 2d3c63817..3c69dbc2b 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -1,4 +1,4 @@ -{{range .Attachments}} +{{- range .Attachments -}}
{{if FilenameIsImage .Name}} @@ -12,4 +12,4 @@
{{.Size | FileSize}}
-{{end}} +{{end -}}