fix: answer an empty checklist with an empty items list
This commit is contained in:
@@ -72,7 +72,7 @@ type checklistJSON struct {
|
||||
Description *string `json:"description"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
Progress checklistProgress `json:"progress"`
|
||||
Items []checklistItemJSON `json:"items,omitempty"`
|
||||
Items *[]checklistItemJSON `json:"items,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
@@ -319,10 +319,11 @@ func checklistsJSON(db *gorm.DB, userID uint, lists []models.Checklist, withItem
|
||||
item.Progress.add(it)
|
||||
}
|
||||
if withItems {
|
||||
item.Items = items[c.ID]
|
||||
if item.Items == nil {
|
||||
item.Items = []checklistItemJSON{}
|
||||
list := items[c.ID]
|
||||
if list == nil {
|
||||
list = []checklistItemJSON{}
|
||||
}
|
||||
item.Items = &list
|
||||
}
|
||||
out = append(out, item)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user