fix: check if vcls.project.Tasks != nil before listing task
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
JD
2024-09-24 17:30:02 -04:00
parent 859c566496
commit 4b05986186

View File

@ -93,19 +93,23 @@ func (vcls *VikunjaCaldavProjectStorage) GetResources(rpath string, withChildren
r := data.NewResource(rpath, &rr)
r.Name = vcls.project.Title
// If the request is withChildren (Depth: 1), we need to return all tasks of the project
if withChildren {
// If the request is withChildren (Depth: 1), we need to return all tasks of the project
var resources []data.Resource
resources = append(resources, r)
for i := range vcls.project.Tasks {
rr := VikunjaProjectResourceAdapter{
project: vcls.project,
task: &vcls.project.Tasks[i].Task,
isCollection: false,
// Check if there are tasks to iterate over
if vcls.project.Tasks != nil {
for i := range vcls.project.Tasks {
taskResource := VikunjaProjectResourceAdapter{
project: vcls.project,
task: &vcls.project.Tasks[i].Task,
isCollection: false,
}
r := data.NewResource(getTaskURL(&vcls.project.Tasks[i].Task), &rr)
r.Name = vcls.project.Tasks[i].Title
resources = append(resources, r)
taskResourceInstance := data.NewResource(getTaskURL(&vcls.project.Tasks[i].Task), &taskResource)
taskResourceInstance.Name = vcls.project.Tasks[i].Title
resources = append(resources, taskResourceInstance)
}
}
return resources, nil
}