fix: check if vcls.project.Tasks != nil before listing task
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user