From ea346668abb73205af1773bfa9d2d7b058f1b953 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Sun, 21 Jun 2026 19:23:14 +0900 Subject: [PATCH] appview/pages: use comment at-uri for internal identifier still use `#comment-{rkey}` for UI, but internal identifier should always use full at-uri. Signed-off-by: Seongmin Lee --- appview/pages/funcmap.go | 9 ++++++++ appview/pages/pages.go | 11 +++++----- .../fragments/comment/commentHeader.html | 2 +- .../templates/repo/fragments/reaction.html | 4 +++- .../templates/repo/fragments/reactions.html | 4 +--- .../repo/fragments/reactionsPopup.html | 10 +++++---- appview/state/reaction.go | 22 +++++++++---------- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go index cb8e533a..17cc456c 100644 --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -458,6 +458,15 @@ func (p *Pages) funcMap() template.FuncMap { "safeUrl": func(s string) template.URL { return template.URL(s) }, + "sanitizeAtUri": func(u syntax.ATURI) string { + s := strings.ToLower(u.String()) + s = strings.TrimPrefix(s, "at://") + s = strings.NewReplacer(":", "-", "/", "-", ".", "-").Replace(s) + return s + }, + "safeCSS": func(s string) template.CSS { + return template.CSS(s) + }, "tinyAvatar": func(handle string) string { return p.AvatarUrl(handle, "tiny") }, diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 3a9abb2d..1b03e14f 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1313,12 +1313,11 @@ func (p *Pages) EditIssueFragment(w io.Writer, params EditIssueParams) error { } type ThreadReactionFragmentParams struct { - Kind models.ReactionKind - Count int - Users []string - IsReacted bool - CommentRkey string - SubjectUri string + Kind models.ReactionKind + Count int + Users []string + IsReacted bool + SubjectUri string } func (p *Pages) ThreadReactionFragment(w io.Writer, params ThreadReactionFragmentParams) error { diff --git a/appview/pages/templates/fragments/comment/commentHeader.html b/appview/pages/templates/fragments/comment/commentHeader.html index 51f814a4..0c86ce83 100644 --- a/appview/pages/templates/fragments/comment/commentHeader.html +++ b/appview/pages/templates/fragments/comment/commentHeader.html @@ -13,7 +13,7 @@ {{ if not .Comment.Deleted }}
{{ if .LoggedInUser }} - {{ template "repo/fragments/reactionsPopup" (dict "CommentRkey" (string .Comment.Rkey) "Scope" "header") }} + {{ template "repo/fragments/reactionsPopup" (dict "SubjectUri" .Comment.AtUri "Scope" "header") }} {{ end }} {{ if $isCommentOwner }} {{ if not .Comment.IsLegacy }} diff --git a/appview/pages/templates/repo/fragments/reaction.html b/appview/pages/templates/repo/fragments/reaction.html index cb1f8b48..c5ab3d36 100644 --- a/appview/pages/templates/repo/fragments/reaction.html +++ b/appview/pages/templates/repo/fragments/reaction.html @@ -1,5 +1,7 @@ {{ define "repo/fragments/reaction" }}
diff --git a/appview/pages/templates/repo/fragments/reactionsPopup.html b/appview/pages/templates/repo/fragments/reactionsPopup.html index 394342b9..3f302a83 100644 --- a/appview/pages/templates/repo/fragments/reactionsPopup.html +++ b/appview/pages/templates/repo/fragments/reactionsPopup.html @@ -1,9 +1,9 @@ {{ define "repo/fragments/reactionsPopup" }} - {{ $id := printf "%s-%s" (string .CommentRkey) .Scope }} + {{ $id := printf "%s-%s" (sanitizeAtUri .SubjectUri) .Scope }} diff --git a/appview/state/reaction.go b/appview/state/reaction.go index e0a5eddf..15b40532 100644 --- a/appview/state/reaction.go +++ b/appview/state/reaction.go @@ -81,12 +81,11 @@ func (s *State) React(w http.ResponseWriter, r *http.Request) { l.Info("created atproto record", "uri", resp.Uri) s.pages.ThreadReactionFragment(w, pages.ThreadReactionFragmentParams{ - Kind: reactionKind, - Count: reactionMap[reactionKind].Count, - Users: reactionMap[reactionKind].Users, - IsReacted: true, - CommentRkey: subjectUri.RecordKey().String(), - SubjectUri: subject, + Kind: reactionKind, + Count: reactionMap[reactionKind].Count, + Users: reactionMap[reactionKind].Users, + IsReacted: true, + SubjectUri: subject, }) return @@ -121,12 +120,11 @@ func (s *State) React(w http.ResponseWriter, r *http.Request) { } s.pages.ThreadReactionFragment(w, pages.ThreadReactionFragmentParams{ - Kind: reactionKind, - Count: reactionMap[reactionKind].Count, - Users: reactionMap[reactionKind].Users, - IsReacted: false, - CommentRkey: subjectUri.RecordKey().String(), - SubjectUri: subject, + Kind: reactionKind, + Count: reactionMap[reactionKind].Count, + Users: reactionMap[reactionKind].Users, + IsReacted: false, + SubjectUri: subject, }) return -- 2.51.2