diff --git a/internal/service/beads.go b/internal/service/beads.go index 4751ca4..e9a191d 100644 --- a/internal/service/beads.go +++ b/internal/service/beads.go @@ -1,10 +1,11 @@ package service import ( - "github.com/LazyBachelor/LazyPM/internal/models" "context" "fmt" + "github.com/LazyBachelor/LazyPM/internal/models" + "github.com/steveyegge/beads" ) @@ -26,6 +27,22 @@ func NewBeadsService(ctx context.Context, storage beads.Storage, prefix string) }, nil } -func (s *BeadsService) AllIssues(ctx context.Context) ([]*models.Issue, error) { - return s.Storage.SearchIssues(ctx, "", models.IssueFilter{}) +func (s *BeadsService) AllIssues(ctx context.Context) ([]models.Issue, error) { + issuesPtr, err := s.Storage.SearchIssues(ctx, "", models.IssueFilter{}) + if err != nil { + return nil, err + } + + if len(issuesPtr) == 0 { + return []models.Issue{}, nil + } + + issues := make([]models.Issue, 0, len(issuesPtr)) + for _, issuePtr := range issuesPtr { + if issuePtr != nil { + issues = append(issues, *issuePtr) + } + } + + return issues, nil } diff --git a/pkg/web/components/issue.templ b/pkg/web/components/issue.templ index b8bcc23..8ed9493 100644 --- a/pkg/web/components/issue.templ +++ b/pkg/web/components/issue.templ @@ -77,7 +77,7 @@ templ IssueForm(props IssueFormProps) { } type IssueTableProps struct { - Issues []*models.Issue + Issues []models.Issue } templ IssueTable(props IssueTableProps) { @@ -96,7 +96,7 @@ templ IssueTable(props IssueTableProps) { ) } -templ IssueRows(issues []*models.Issue) { +templ IssueRows(issues []models.Issue) { for _, issue := range issues { { issue.ID } diff --git a/pkg/web/components/issue_templ.go b/pkg/web/components/issue_templ.go index 0a4e123..2e66cf0 100644 --- a/pkg/web/components/issue_templ.go +++ b/pkg/web/components/issue_templ.go @@ -155,7 +155,7 @@ func IssueForm(props IssueFormProps) templ.Component { } type IssueTableProps struct { - Issues []*models.Issue + Issues []models.Issue } func IssueTable(props IssueTableProps) templ.Component { @@ -199,7 +199,7 @@ func IssueTable(props IssueTableProps) templ.Component { }) } -func IssueRows(issues []*models.Issue) templ.Component { +func IssueRows(issues []models.Issue) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {