Monorepo for Tangled tangled.org

appview: unified comment fragments/handlers #1276

open opened by boltless.me targeting master from sl/comment

share as much handlers/fragments as possible. PR has still /.../comment endpoint to serve comment form htmx fragment. Due to how it is designed.

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mimbhgiqjb22
+56 -22
Interdiff #5 #6
appview/db/comments.go

This file has not been changed.

+7 -7
appview/ingester.go
··· 1031 1031 return fmt.Errorf("failed to validate comment: %w", err) 1032 1032 } 1033 1033 1034 - var mentions []syntax.DID 1035 1034 var references []syntax.ATURI 1036 1035 if comment.Body.Original != nil { 1037 - mentions, references = i.MentionsResolver.Resolve(ctx, *comment.Body.Original) 1036 + _, references = i.MentionsResolver.Resolve(ctx, *comment.Body.Original) 1038 1037 } 1039 1038 1040 1039 tx, err := ddb.Begin() ··· 1052 1051 return err 1053 1052 } 1054 1053 1055 - if e.Commit.Operation == jmodels.CommitOperationCreate { 1056 - i.Notifier.NewComment(ctx, comment, mentions) 1057 - } 1058 - 1059 1054 case jmodels.CommitOperationDelete: 1060 1055 if err := db.DeleteComments( 1061 1056 ddb, ··· 1193 1188 return fmt.Errorf("failed to validate comment: %w", err) 1194 1189 } 1195 1190 1191 + var mentions []syntax.DID 1196 1192 var references []syntax.ATURI 1197 1193 if comment.Body.Original != nil { 1198 - _, references = i.MentionsResolver.Resolve(ctx, *comment.Body.Original) 1194 + mentions, references = i.MentionsResolver.Resolve(ctx, *comment.Body.Original) 1199 1195 } 1200 1196 1201 1197 tx, err := ddb.Begin() ··· 1213 1209 return err 1214 1210 } 1215 1211 1212 + if e.Commit.Operation == jmodels.CommitOperationCreate { 1213 + i.Notifier.NewComment(ctx, comment, mentions) 1214 + } 1215 + 1216 1216 case jmodels.CommitOperationDelete: 1217 1217 if err := db.DeleteComments( 1218 1218 ddb,
appview/issues/issues.go

This patch was likely rebased, as context lines do not match.

appview/issues/router.go

This file has not been changed.

appview/models/comment.go

This file has not been changed.

+14 -14
appview/pages/pages.go
··· 1593 1593 return p.execute("timeline/home", w, params) 1594 1594 } 1595 1595 1596 + func (p *Pages) Static() http.Handler { 1597 + if p.dev { 1598 + return http.StripPrefix("/static/", http.FileServer(http.Dir("appview/pages/static"))) 1599 + 1600 + 1601 + 1602 + 1603 + 1604 + 1605 + 1606 + 1607 + return p.execute("timeline/home", w, params) 1608 + } 1609 + 1596 1610 type CommentBodyFragmentParams struct { 1597 1611 Comment models.Comment 1598 1612 } ··· 1626 1640 } 1627 1641 1628 1642 func (p *Pages) Static() http.Handler { 1629 - if p.dev { 1630 - return http.StripPrefix("/static/", http.FileServer(http.Dir("appview/pages/static"))) 1631 - 1632 - 1633 - 1634 - 1635 - 1636 - 1637 - 1638 - 1639 - return p.execute("timeline/home", w, params) 1640 - } 1641 - 1642 - func (p *Pages) Static() http.Handler { 1643 1643 if p.dev { 1644 1644 return http.StripPrefix("/static/", http.FileServer(http.Dir("appview/pages/static")))
appview/pages/templates/fragments/comment/commentBody.html

This file has not been changed.

appview/pages/templates/fragments/comment/commentHeader.html

This patch was likely rebased, as context lines do not match.

appview/pages/templates/fragments/comment/edit.html

This file has not been changed.

appview/pages/templates/fragments/comment/reply.html

This file has not been changed.

appview/pages/templates/fragments/comment/replyPlaceholder.html

This file has not been changed.

appview/pages/templates/repo/issues/fragments/commentList.html

This file has not been changed.

+34
appview/pages/templates/repo/issues/fragments/issueCommentActions.html
··· 1 + {{ define "repo/issues/fragments/issueCommentActions" }} 2 + {{ $isCommentOwner := and .LoggedInUser (eq .LoggedInUser.Did .Comment.Did) }} 3 + {{ if and $isCommentOwner (not .Comment.Deleted) }} 4 + <div class="flex flex-wrap items-center gap-4 text-gray-500 dark:text-gray-400 text-sm pt-2"> 5 + {{ template "edit" . }} 6 + {{ template "delete" . }} 7 + </div> 8 + {{ end }} 9 + {{ end }} 10 + 11 + {{ define "edit" }} 12 + <a 13 + class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer" 14 + hx-get="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment/{{ .Comment.Id }}/edit" 15 + hx-swap="outerHTML" 16 + hx-target="#comment-body-{{.Comment.Id}}"> 17 + {{ i "pencil" "size-3" }} 18 + edit 19 + </a> 20 + {{ end }} 21 + 22 + {{ define "delete" }} 23 + <a 24 + class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer" 25 + hx-delete="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment/{{ .Comment.Id }}/" 26 + hx-confirm="Are you sure you want to delete your comment?" 27 + hx-swap="outerHTML" 28 + hx-target="#comment-body-{{.Comment.Id}}" 29 + > 30 + {{ i "trash-2" "size-3" }} 31 + delete 32 + {{ i "loader-circle" "size-3 animate-spin hidden group-[.htmx-request]:inline" }} 33 + </a> 34 + {{ end }}
appview/pages/templates/repo/issues/fragments/newComment.html

This patch was likely rebased, as context lines do not match.

appview/pages/templates/repo/issues/fragments/replyComment.html

This file has not been changed.

appview/pages/templates/repo/issues/fragments/replyIssueCommentPlaceholder.html

This file has not been changed.

appview/pages/templates/repo/pulls/fragments/pullActions.html

This file has not been changed.

appview/pages/templates/repo/pulls/fragments/pullNewComment.html

This file has not been changed.

appview/pages/templates/repo/pulls/pull.html

This patch was likely rebased, as context lines do not match.

appview/pulls/pulls.go

This patch was likely rebased, as context lines do not match.

appview/pulls/router.go

This file has not been changed.

+1 -1
appview/state/comment.go
··· 325 325 326 326 err = db.PutComment(tx, &newComment, references) 327 327 if err != nil { 328 - l.Error("failed to perferom update-description query", "err", err) 328 + l.Error("failed to perform update-description query", "err", err) 329 329 s.pages.Notice(w, noticeId, "Failed to update comment, try again later.") 330 330 return 331 331 }
appview/state/router.go

This patch was likely rebased, as context lines do not match.

appview/strings/strings.go

This file has not been changed.

History

10 rounds 4 comments
sign up or login to add to the discussion
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 4 comments

appview/pages/templates/fragments/comment/edit.html:2 now opens with form, I don't see a /form close in this diff tho

appview/state/comment.go:385-388 also how about a db.DeleteComments() from our sqlite?

appview/state/comment.go:249-268 comment.Validate() warranted just in case?

now opens with form, I don't see a /form close in this diff tho

how could I miss that. Thanks for pointing out.

how about a db.DeleteComments() from our sqlite?

I didn't do that on purpose. Comment deletion event will/should be ingested from appview ingester. For create/update events, it makes sense to do that on web handler because we can avoid parsing markdown again. But for delete event, we just don't need to delete records on web handler. Even if something goes wrong, it's ingester's job to retry, not web handlers.

comment.Validate() warranted just in case?

good idea. will add it.

1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments
1 commit
expand
appview: unified comment fragments/handlers
3/3 failed
expand
expand 0 comments