use beads service

use pointes for comments
use htmx routing
This commit is contained in:
Robin Olsen
2026-02-22 11:03:31 +01:00
parent 15f8bbb8ed
commit 2e4185e30f
12 changed files with 403 additions and 358 deletions

View File

@@ -92,7 +92,7 @@ func IssueCtx(next http.Handler) http.Handler {
return
}
comments, err := svc.Beads.GetComments(r.Context(), issue.ID)
comments, err := svc.Beads.GetIssueComments(r.Context(), issue.ID)
if err != nil {
http.Error(w, "Error getting comments: "+err.Error(), http.StatusInternalServerError)
return
@@ -107,13 +107,10 @@ func IssueCtx(next http.Handler) http.Handler {
func GetIssue(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
comments := r.Context().Value(commentsKey).([]models.Comment)
comments := r.Context().Value(commentsKey).([]*models.Comment)
hx := HTMX(r)
acceptHeader := r.Header.Get("Accept")
wantsHTML := acceptHeader == "" || strings.Contains(acceptHeader, "text/html")
if wantsHTML && !hx.IsHxRequest() {
if !hx.IsHxRequest() && strings.Contains(r.Header.Get("Accept"), "text/html") {
routes.IssueDetail(routes.IssueDetailProps{
Issue: *issue,
Comments: comments,
@@ -121,6 +118,14 @@ func GetIssue(w http.ResponseWriter, r *http.Request) {
return
}
if hx.IsHxRequest() {
routes.IssueDetailContent(routes.IssueDetailProps{
Issue: *issue,
Comments: comments,
}).Render(r.Context(), w)
return
}
w.Header().Set("Content-Type", "application/json")
hx.WriteJSON(issue)
}