From c0cf6911f13a6bc603579bfc86c06145d288f1b5 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 12 Jun 2026 16:36:14 +0300 Subject: [PATCH] appview/comment: on comment deletion, swap-oob a new comment header the new header includes the correct timestamp, removes the hover buttons etc. Signed-off-by: oppiliappan --- appview/pages/pages.go | 11 ++++++++ .../fragments/comment/commentHeader.html | 26 +++++++++---------- .../fragments/comment/commentList.html | 4 +-- appview/pages/templates/repo/pulls/pull.html | 3 +-- appview/state/comment.go | 4 +++ 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 54f71e83..d1ea52a2 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1731,6 +1731,17 @@ func (p *Pages) CommentBodyFragment(w io.Writer, params CommentBodyFragmentParam return p.executePlain("fragments/comment/commentBody", w, params) } +type CommentHeaderFragmentParams struct { + Comment models.Comment + Reactions map[models.ReactionKind]models.ReactionDisplayData + UserReacted map[models.ReactionKind]bool + HxSwapOob bool +} + +func (p *Pages) CommentHeaderFragment(w io.Writer, params CommentHeaderFragmentParams) error { + return p.executePlain("fragments/comment/commentHeader", w, params) +} + type EditCommentFragmentParams struct { Comment models.Comment } diff --git a/appview/pages/templates/fragments/comment/commentHeader.html b/appview/pages/templates/fragments/comment/commentHeader.html index 2092c8e2..8fcd6181 100644 --- a/appview/pages/templates/fragments/comment/commentHeader.html +++ b/appview/pages/templates/fragments/comment/commentHeader.html @@ -2,29 +2,25 @@
{{ $handle := resolve .Comment.Did.String }} {{ $handle }} - {{ template "hats" $ }} {{ template "timestamp" . }} {{ $isCommentOwner := and .LoggedInUser (eq .LoggedInUser.Did .Comment.Did.String) }} {{ if and $isCommentOwner (not .Comment.Deleted) }} - {{ if not .Comment.IsLegacy }} - {{ template "editCommentBtn" . }} - {{ end }} - {{ template "deleteCommentBtn" . }} +
+ {{ if not .Comment.IsLegacy }} + {{ template "editCommentBtn" . }} + {{ end }} + {{ template "deleteCommentBtn" . }} +
{{ end }}
{{ end }} -{{ define "hats" }} - {{ $isIssueAuthor := eq .Comment.Did .Issue.Did }} - {{ if $isIssueAuthor }} - (author) - {{ end }} -{{ end }} - {{ define "timestamp" }} {{ i "pencil" "size-3 inline group-[.htmx-request]:hidden" }} {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }} + edit {{ end }} {{ define "deleteCommentBtn" }} {{ i "trash-2" "size-3 inline group-[.htmx-request]:hidden" }} {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }} + delete {{ end }} diff --git a/appview/pages/templates/fragments/comment/commentList.html b/appview/pages/templates/fragments/comment/commentList.html index d10715e7..e7697edd 100644 --- a/appview/pages/templates/fragments/comment/commentList.html +++ b/appview/pages/templates/fragments/comment/commentList.html @@ -42,7 +42,7 @@ {{ end }} {{ define "topLevelComment" }} -
+
{{ template "user/fragments/picLink" (list .Comment.Did.String "size-8 mr-1" .VouchRelationship) }}
@@ -54,7 +54,7 @@ {{ end }} {{ define "replyComment" }} -
+
{{ template "user/fragments/picLink" (list .Comment.Did.String "size-8 mr-1" .VouchRelationship) }}
diff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html index ef816edf..6b7c1df0 100644 --- a/appview/pages/templates/repo/pulls/pull.html +++ b/appview/pages/templates/repo/pulls/pull.html @@ -595,7 +595,6 @@
{{ range $item.Comments }} - {{/* template "submissionComment" . */}} {{ template "comment" (dict "LoggedInUser" $root.LoggedInUser "Reactions" (index (asReactionMapMap $root.Reactions) .FeedCommentAtUri) @@ -636,7 +635,7 @@ {{ end }} {{ define "comment" }} -
+
{{ template "user/fragments/picLink" (list .Comment.Did.String "size-8") }} diff --git a/appview/state/comment.go b/appview/state/comment.go index 4af31d6c..207d7e93 100644 --- a/appview/state/comment.go +++ b/appview/state/comment.go @@ -460,4 +460,8 @@ func (s *State) DeleteComment(w http.ResponseWriter, r *http.Request) { s.pages.CommentBodyFragment(w, pages.CommentBodyFragmentParams{ Comment: comment, }) + s.pages.CommentHeaderFragment(w, pages.CommentHeaderFragmentParams{ + Comment: comment, + HxSwapOob: true, + }) } -- 2.51.2